Practice Problem

Meeting Rooms

Difficulty: Easy

Given an array of meeting time intervals, determine if a person could attend all meetings without any overlap.

Meeting Rooms

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

Return true if a person can attend all meetings without any overlap, and false otherwise.

Two meetings overlap if one starts before the other ends. Meetings that share an exact boundary (one ends at time t and another starts at time t) do not overlap.

Examples

Example 1:

Input: intervals = [[0, 30], [5, 10], [15, 20]]
Output: false
Explanation: The meeting [0,30] overlaps with [5,10] and [15,20].

Example 2:

Input: intervals = [[7, 10], [2, 4]]
Output: true
Explanation: After sorting by start time: [2,4] and [7,10]. No overlap.

Example 3:

Input: intervals = [[1, 5], [5, 10]]
Output: true
Explanation: The first meeting ends at 5 and the second starts at 5. They share a boundary but do not overlap.

Constraints

  • 0 <= intervals.length <= 10^4
  • intervals[i].length == 2
  • 0 <= start_i < end_i <= 10^6

Expected Complexity

  • Time: O(n log n). dominated by sorting
  • Space: O(1). excluding the space used by sorting
EASY
Interval Problems
Sorting
Beginner

0 views

Solution

Hints

Hint 1
Hint 2
Premium
Hint 3
Premium