Practice

Meeting Rooms

Module 21 · Intervals

Problem

Given an array of meeting time intervals [start, end], determine whether a person could attend all of them — that is, return true if no two meetings overlap, and false otherwise. A meeting ending exactly when another begins does not count as a conflict.

Examples

Example 1

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

Explanation. [0,30] overlaps both others

Example 2

Input[[7,10],[2,4]]Outputtrue

Explanation. 2–4 finishes before 7–10 starts

Example 3

Input[[1,5],[5,8]]Outputtrue

Explanation. touching endpoints are fine

Constraints

0 ≤ n ≤ 10⁴.

Attempt it first

This is the boolean cousin of Module 14's Meeting Rooms II. That problem asked "how many rooms are needed at once?" and required real machinery — a heap or a two-pointer sweep over separated endpoints. This one asks only "is one room ever enough?", i.e. "do any two meetings overlap at all?" That is a strictly easier question, and it should need strictly less machinery. Find the one-pass check before opening the hint.