72. Meeting Rooms

Given an array of meeting time intervals, where intervals[i] = [starti, endi] represents the start and end times of the i-th meeting, determine whether a person can attend all meetings without any overlap.

Two meetings are considered overlapping if one meeting starts before the other meeting ends. If one meeting ends exactly when another begins, they are not considered overlapping, and the person can attend both.

Note:

• The input array of meeting intervals is not necessarily sorted by start time.

Example 1:

Input: intervals = [[1, 5], [3, 8], [6, 10], [12, 15]]

Output: false

Explanation: Overlapping meetings exist at [1,5] and [3,8], making it impossible to attend all.

Example 2:

Input: intervals = [[2, 6], [7, 9], [10, 14], [15, 18]]

Output: true

Explanation: No overlapping meetings, so all can be attended.

Now Your Turn!

Pick the correct output for the given input

Input: intervals = [[0, 4], [4, 9], [10, 13], [14, 17]]

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 0 <= intervals.length <= 104
  • intervals[i].length == 2
  • 0 <= starti < endi <= 106

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

Fun Facts

0
class Solution {
public:
bool canAttendMeetings(vector<vector<int>>& intervals) {
// Your code goes here
}
};
Test Case

Input:

Intervals