Skip to content

Commit 21d1261

Browse files
committed
feat: meeting rooms
1 parent 0d3d922 commit 21d1261

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

โ€Žmeeting-rooms/anniemon.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* ์‹œ๊ฐ„ ๋ณต์žก๋„: ์ •๋ ฌ์˜ ์‹œ๊ฐ„ ๋ณต์žก๋„์™€ ๊ฐ™์Œ. O(nlogn)
3+
* ๊ณต๊ฐ„ ๋ณต์žก๋„: ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์˜ ์ •๋ ฌ์€ Timsort๋ฅผ ์‚ฌ์šฉ. ๋”ฐ๋ผ์„œ ์ตœ์•…์˜ ๊ฒฝ์šฐ ๊ณต๊ฐ„ ๋ณต์žก๋„๋Š” O(n)
4+
*/
5+
/**
6+
* Definition of Interval:
7+
* class Interval {
8+
* constructor(start, end) {
9+
* this.start = start;
10+
* this.end = end;
11+
* }
12+
* }
13+
*/
14+
15+
class Solution {
16+
/**
17+
* @param {Interval[]} intervals
18+
* @returns {boolean}
19+
*/
20+
canAttendMeetings(intervals) {
21+
intervals.sort((a,b) => a.start - b.start)
22+
23+
for(let i = 1; i < intervals.length; i++) {
24+
if(intervals[i].start < intervals[i-1].end) {
25+
return false;
26+
}
27+
}
28+
return true;
29+
}
30+
}

0 commit comments

Comments
ย (0)