forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_252.java
More file actions
23 lines (21 loc) · 662 Bytes
/
_252.java
File metadata and controls
23 lines (21 loc) · 662 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.fishercoder.solutions;
import java.util.Arrays;
public class _252 {
public static class Solution1 {
public boolean canAttendMeetings(int[][] intervals) {
if (intervals == null || intervals.length == 0) {
return true;
}
Arrays.sort(intervals, (a, b) -> a[0] - b[0]);
int end = intervals[0][1];
for (int i = 1; i < intervals.length; i++) {
if (intervals[i][0] < end) {
return false;
} else {
end = intervals[i][1];
}
}
return true;
}
}
}