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 2ed7544 commit 167967cCopy full SHA for 167967c
1 file changed
meeting-rooms/YoungSeok-Choi.java
@@ -0,0 +1,39 @@
1
+import java.util.Collections;
2
+import java.util.Comparator;
3
+import java.util.List;
4
+
5
+class Interval {
6
+ int start, end;
7
8
+ Interval(int start, int end) {
9
+ this.start = start;
10
+ this.end = end;
11
+ }
12
+}
13
14
+class Solution {
15
16
+ public boolean canAttendMeetings(List<Interval> intervals) {
17
+ Collections.sort(intervals, new Comparator<Interval>() {
18
+ @Override
19
+ public int compare(Interval i1, Interval i2) {
20
+ if (i1.start == i2.start) {
21
+ return i1.end - i2.end;
22
23
24
+ return i1.start - i2.start;
25
26
+ });
27
28
+ int prevEnd = -987654321;
29
+ for (Interval anInt : intervals) {
30
+ if (anInt.start < prevEnd) {
31
+ return false;
32
33
34
+ prevEnd = anInt.end;
35
36
37
+ return true;
38
39
0 commit comments