We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c8d452b commit 62fca0dCopy full SHA for 62fca0d
meeting-rooms/TonyKim9401.java
@@ -0,0 +1,17 @@
1
+// TC: O(n log n)
2
+// list sort
3
+// SC: O(n)
4
+// list sort max use O(n)
5
+public class Solution {
6
+ public boolean canAttendMeetings(List<Interval> intervals) {
7
+ intervals.sort(Comparator.comparingInt(o -> o.start));
8
+
9
+ for (int i = 0; i < intervals.size() - 1; i++) {
10
+ Interval preInterval = intervals.get(i);
11
+ Interval postInterval = intervals.get(i+1);
12
13
+ if (preInterval.end > postInterval.start) return false;
14
+ }
15
+ return true;
16
17
+}
0 commit comments