Intervals Merging and scheduling
509. Meeting Rooms
You are given an array intervals, where intervals[i] = [start, end] is a meeting that starts at time
start and ends at time end. Return true if one person can attend every meeting, and false otherwise.
A person cannot be in two meetings at once. Two meetings clash when one starts before the other ends. A
meeting may start at the moment another one ends, so [1,5] and [5,8] do not clash.
Example 1
Input: intervals = [[10, 12], [1, 5], [6, 10], [13, 14]]
trueExplanation: In time order the meetings are [1,5], [6,10], [10,12] and [13,14]. [10,12] starts just as
[6,10] ends, which is allowed, and no two others meet at all.
Example 2
Input: intervals = [[2, 9], [11, 15], [4, 6]]
falseExplanation: [4,6] lies inside [2,9], so the person cannot be at both.
Example 3
Input: intervals = []
trueExplanation: There are no meetings, so nothing can clash.
Check your understanding
Work out the answer for this input before you write any code.
Constraints
0 ≤ intervals.length ≤ 105intervals[i].length = 20 ≤ start < end ≤ 109
Clarifying questions
What you would ask an interviewer before writing any code.