Facebook Pixel

Meeting Rooms

Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings.

Input

  • intervals: an array of meeting time intervals where intervals[i] = [starti, endi]

Output

true if a person could attend all meetings, false otherwise

Examples

Example 1:

Input:

intervals = [[0,30],[5,10],[15,20]]

Output: false

Explanation:

The meetings overlap, so a person cannot attend all meetings.

Example 2:

Input:

intervals = [[7,10],[2,4]]

Output: true

Explanation:

The meetings don't overlap, so a person can attend all meetings.

Example 3:

Input:

intervals = [[0,30],[5,10],[15,20],[5,15]]

Output: false

Explanation:

The meetings overlap, so a person cannot attend all meetings.

Constraints

  • 1 <= intervals.length <= 10^4
  • 0 <= starti < endi <= 10^6

Try it yourself

Solution

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro