DSA · Intervals · #117
Meeting Rooms
Module 67 · difficulty 2/5·⏱ 30:00starts on first keystroke
Given an array `intervals` where `intervals[i] = [start_i, end_i]` represents the start and end times of a meeting, determine if a single person could attend **all** meetings. Two meetings conflict if they overlap in time. A meeting that ends exactly when another begins (`end_i === start_j`) does **not** conflict — back-to-back meetings are fine. Implement `canAttendMeetings(intervals)` which returns `true` if no meetings overlap, otherwise `false`.
Examples
intervals = [[0,30],[5,10],[15,20]]→false— [0,30] overlaps both [5,10] and [15,20], so one person can't attend all.intervals = [[7,10],[2,4]]→true— After sorting: [2,4] then [7,10] — no overlap.intervals = [[1,5],[5,8]]→true— Touching endpoints (5 === 5) are not a conflict.
Constraints
- · 0 <= intervals.length <= 10^4
- · intervals[i].length === 2
- · 0 <= start_i < end_i <= 10^6
Session phases
A · Clarify
B · Approach
C · Complexity
D · Edges
E · Code
F · Tradeoff
G · Score
Phase A — Clarify
Ask questions about input bounds, types, and edge constraints.
Ask the coach clarifying questions about the problem.
When you've covered this phase, advance to the next.