Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],…] (si < ei), determine if a person could attend all meetings.
For example, Given [[0, 30],[5, 10],[15, 20]], return false.
Solution
Analysis
Solution1
Store all start time into one array, sort it.
Store all stop time into one array, sort it.
Use the current start time to compare with the previous stop time, if begin[i]<stop[i-1], then overlap.
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
/**
* Definition for an interval.
* publicclass Interval {
* int start;
* intend;
* Interval() { start = 0; end = 0; }
* Interval(int s, int e) { start = s; end = e; }
* }
*/
publicclass Solution {
public boolean canAttendMeetings(Interval[] intervals) {