solulubeta
Sign in
NeetCode 150 / Intervals
16.04 · Problem

Meeting Rooms

Easy Sort by start, check neighbours 1 video LC 252 Free
Meeting Rooms — NeetCode· NeetCode

Given meeting times [start, end], return true if one person can attend all of them (no two meetings overlap). A meeting ending at time t and another starting at t don’t conflict.

Examples

Input:  intervals = [[0,30],[5,10],[15,20]]
Output: false

Input:  intervals = [[7,10],[2,4]]
Output: true

Constraints

  • 0 ≤ intervals.length ≤ 10⁴, 0 ≤ start < end ≤ 10⁶

Explanation

Compare every pair

Check all pairs for overlap: O(n²).

Sort by start

After sorting by start time, if any two meetings overlap then some adjacent pair overlaps. So check only neighbours: meeting i must start at or after meeting i − 1 ends.

Complexity

  • Time: O(n log n). Space: O(1) beyond sorting.
Loading the workspace…
Mark this problem as solved when you are finished.

Item 133 of 150 · updated 2026-10-12