Meeting Rooms
Problem statement
You are given a list of meetings, intervals, where intervals[i] = [starti, endi]. A meeting takes up the time from starti up to, but not including, endi.
Return true if one person can attend every meeting, meaning no two meetings overlap. Otherwise return false.
Two meetings overlap when they share some moment of time. A meeting that ends at time t and another that starts at time t do not overlap.
Function
canAttendMeetings(intervals: int[][]) → booleanExamples
Example 1
intervals = [[9,12],[13,15],[11,14]]return = falseThe meetings [9, 12] and [11, 14] both take up the time from 11 to 12, so one person cannot attend both.
Example 2
intervals = [[4,7],[1,4],[7,10]]return = trueIn start order the meetings are [1, 4], [4, 7], and [7, 10]. Each one starts exactly when the one before it ends, which is allowed.
Example 3
intervals = [[5,8]]return = trueThere is only one meeting, so nothing can overlap.
Constraints
1 <= intervals.length <= 5000intervals[i].length == 20 <= starti < endi <= 10^6