Given array of a schedule of meetings, each meeting will include the start time and end time of [[s1, e1], [s2, e2], ...] (si <ei), you can determine whether a person participate in all the meetings there.
Example 1:
Input: [[0,30], [5,10], [15,20]]
Output: false
Example 2:
Input: [[7,10], [2,4]]
Output: true
Idea: according to the start time of ordering, each conference to determine whether there is overlap time can be.
class Solution {
public boolean canAttendMeetings(int[][] intervals) {
if(intervals == null || intervals.length==0)return true;
Arrays.sort(intervals, new Comparator<int[]>() {
@Override
public int compare(int[] o1, int[] o2) {
return o1[0] - o2[0];
}
});
for(int i=0;i+1<intervals.length;i++){
if(intervals[i][1]>intervals[i+1][0])return false;
}
return true;
}
}