Search lands in PR-5.1 (Pagefind).

How-to Beginner

Chapter 1 Updated

Meeting Rooms I — Conflict Detection

Sort by start, check consecutive pairs — done.

  • Full 4m
  • Revision 2m
  • Flow 1m

Problem

LeetCode #252 — one-liner.

  • Given meeting intervals, can one person attend all of them? Return true / false.

Key insight

Adjacency after sorting.

  • After sorting by start, overlapping meetings must be adjacent.
  • So the check reduces to: does any meeting start before its predecessor ends?

Solution template

Two lines of logic.

intervals.sort(key=lambda x: x[0])
for i in range(1, len(intervals)):
    if intervals[i][0] < intervals[i - 1][1]:
        return False
return True

Complexity

Sort dominates.

  • Time O(n log n) — sort; the scan is O(n).
  • Space O(1) — in-place sort, no extra structure.

Edge cases

Three to remember.

  • 0 or 1 meetings → trivially true.
  • [1,2] + [2,3] — half-open: no conflict (2 < 2 is false). Closed: conflict ().
  • All meetings at the same time → first pair already conflicts.

Comments

Comments are disabled in this environment. Set PUBLIC_GISCUS_REPO, PUBLIC_GISCUS_REPO_ID, and PUBLIC_GISCUS_CATEGORY_ID to enable.