252. 会议室
就是先排序,再看有没有重叠的
class Solution {
public boolean canAttendMeetings(int[][] intervals) {
if(intervals == null || intervals.length == 0) return true;
Arrays.sort(intervals, (e1,e2)->{
return e1[0] - e2[0];
});
int start = intervals[0][0];
int end = intervals[0][1];
for (int i = 1 ; i < intervals.length; i++) {
if(intervals[i][0] < end) {
return false;
}
start = intervals[i][0];
end = intervals[i][1];
}
return true;
}
}
网友评论