forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_252.java
32 lines (27 loc) · 814 Bytes
/
_252.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.fishercoder.solutions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class _252 {
public static class Solution1 {
public boolean canAttendMeetings(int[][] intervals) {
List<int[]> list = new ArrayList();
for (int[] interval : intervals) {
list.add(interval);
}
Collections.sort(list, (o1, o2) -> {
if (o1[0] > o2[0]) {
return 1;
} else {
return -1;
}
});
for (int i = 0; i < list.size() - 1; i++) {
if (list.get(i)[1] > list.get(i + 1)[0]) {
return false;
}
}
return true;
}
}
}