Meeting Room 1 and Meeting Room 2 of Leetcode
Meeting Room 1 and Meeting Room 2 of Leetcode 252. Meeting Rooms Given an array of meeting time intervals where intervals[i] = [start i , end i ] , determine if a person could attend all meetings. Example 1: Input: intervals = [[0,30],[5,10],[15,20]] Output: false Example 2: Input: intervals = [[7,10],[2,4]] Output: true Solution: Sort according to Ending time. public boolean canAttendMeetings ( int [][] intervals ) { Arrays . sort (intervals, ( int [] a, int [] b) -> { return a[ 1 ] - b[ 1 ]; }); int n = intervals . length ; for ( int i = 1 ;i<n;i++){ int st = intervals[i][ 0 ]; int en = intervals[i][ 1 ]; if (st < intervals[i- 1 ][ 1 ]){ return false ; } } return true ; }