AceYourInterviews
Checking sign-in…

38. Meeting Rooms — Conflict Detection

IntermediateStart-order adjacent conflict detection

Decide whether one person can attend every meeting from beginning to end without being in two meetings at the same time. The input order need not already be chronological.

A meeting ending exactly when another begins does not create a conflict. You are deciding feasibility for one attendee, rather than counting the number of rooms.

Example 1

Input

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

Output

false

Explanation: The first long meeting conflicts with the meeting starting at five.

Example 2

Input

[[7,10],[2,4],[4,7]]

Output

true

Explanation: Sorting gives a compatible chain; equal end/start boundaries do not overlap.

Constraints

  • 0 <= meetings.length <= 105
  • meetings[i].length == 2
  • -231 <= start < end <= 231 - 1
Hints
Hint 1

After sorting by start, where must the first conflict appear?

Hint 2

What does a conflict-free prefix tell you about all its earlier end times?

Hint 3

Reject an adjacent strict overlap; otherwise extend the compatible chain.

Practice on LeetCode ↗ · Premium
Code
Saved on this deviceLn 1, Col 1

An unsorted compatible chain

[[7,10],[2,4],[4,7]]
true