Facebook PixelMeeting Rooms — Coding Practice
Meeting RoomsEasy

Meeting Rooms

Easy 4.3k56% acceptance
ArrayIntervalsSorting

Given an array of meeting time intervals where intervals[i] = [startᵢ, endᵢ], determine whether a single person could attend every meeting — that is, return true if no two meetings overlap and false otherwise.

A meeting that ends exactly when another begins (e.g. [0,30] then [30,60]) does not conflict.

Example 1
Input: intervals = [[0,30],[5,10],[15,20]]
Output: false
[0,30] overlaps [5,10], so they cannot both be attended.
Example 2
Input: intervals = [[7,10],[2,4]]
Output: true
The two meetings do not overlap.
Example 3
Input: intervals = [[0,30],[30,60]]
Output: true
Back-to-back meetings are fine.
Constraints
  • 0 ≤ intervals.length ≤ 10⁴
  • intervals[i].length == 2
  • 0 ≤ startᵢ < endᵢ ≤ 10⁶
Asked atMetaAmazonGoogleMicrosoft
JavaScript
Loading editor…
Case 1
[[0,30],[5,10],[15,20]]
expected: false
Case 2
[[7,10],[2,4]]
expected: true
Case 3
[[0,30],[30,60]]
expected: true
Case 4
[]
expected: true
Case 5
[[5,8]]
expected: true
Case 6
[[1,5],[5,10],[10,15],[4,6]]
expected: false