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 1505e9e commit a487156Copy full SHA for a487156
meeting-rooms/eunhwa99.java
@@ -0,0 +1,26 @@
1
+
2
+// TC: O(N)
3
+// SC: O(1)
4
+class Solution {
5
+ /**
6
+ * @param intervals: an array of meeting time intervals
7
+ * @return: if a person could attend all meetings
8
+ */
9
+ public boolean canAttendMeetings(List<Interval> intervals) {
10
+ // Edge case: empty list or single meeting
11
+ if (intervals == null || intervals.size() <= 1) {
12
+ return true;
13
+ }
14
15
+ intervals.sort(Comparator.comparing(v->v.start));
16
17
+ int prevEndTime = intervals.get(0).end;
18
+ for(int i = 1; i < intervals.size(); i++){
19
+ Interval cur = intervals.get(i);
20
+ if(cur.start < prevEndTime) return false;
21
+ prevEndTime = cur.end;
22
23
24
25
+}
26
0 commit comments