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
/** * Definition for an interval. * public class Interval { * int start; * int end; * Interval() { start = 0; end = 0; } * Interval(int s, int e) { start = s; end = e; } * } */publicclassSolution {publicbooleancanAttendMeetings(Interval[] intervals) {if (intervals ==null||intervals.length<=1) returntrue;Arrays.sort(intervals, (a, b) ->a.start-b.start);for (int i =1; i <intervals.length; i++) {Interval m = intervals[i -1];Interval n = intervals[i];if (m.end>n.start||m.start==n.start) {returnfalse; } }returntrue; }}