Skip to content

Commit d2358f7

Browse files
committed
[week3] solve 252. Meeting Rooms
1 parent f7093c5 commit d2358f7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

meeting-rooms/bky373.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
3+
public boolean canAttendMeetings(int[][] intervals) {
4+
if (intervals.length == 0) {
5+
return true;
6+
}
7+
Arrays.sort(intervals, (o1, o2) -> o1[0] - o2[0]);
8+
for (int i = 0; i < intervals.length - 1; i++) {
9+
if (intervals[i][1] > intervals[i + 1][0]) {
10+
return false;
11+
}
12+
}
13+
return true;
14+
}
15+
}
16+
/**
17+
* TC: O(nlogn), due to the sorting array.
18+
* SC: O(1)
19+
*/

0 commit comments

Comments
 (0)