Check Whether One Person Can Attend Every Meeting

Quick Overview

A coding question that asks whether one person can attend every meeting in a list of half-open time intervals. It tests interval reasoning, correct treatment of back-to-back and duplicate meetings, and an efficient overlap check that scales to a hundred thousand meetings.

Check Whether One Person Can Attend Every Meeting

Company: ByteDance

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

A person has a list of meetings, each with a start time and an end time. Return whether they can attend every meeting, which is possible exactly when no two meetings overlap. ### Function Signature ```python def can_attend_all(meetings: list[list[int]]) -> bool: ``` ### Rules - `meetings[i] = [start, end]` occupies the half-open interval `[start, end)`: the meeting is in progress at every time `t` with `start <= t < end`. - Two meetings overlap when some time `t` lies in both intervals. A meeting that ends at `t` and a meeting that starts at `t` do not overlap. - Identical meetings listed twice are separate meetings, and they overlap each other. - Return `True` when there are zero meetings or one meeting. ### Constraints - `0 <= len(meetings) <= 10^5` - `0 <= start < end <= 10^9` for every meeting - Times are integers, so every value fits in a 32-bit signed integer. - `meetings` is in no particular order. ### Examples **Example 1** ```text Input: meetings = [[9, 12], [1, 4], [4, 9]] Output: True ``` In time order the meetings are `[1, 4)`, `[4, 9)` and `[9, 12)`. Each one starts exactly when the previous one ends, so none overlap. **Example 2** ```text Input: meetings = [[2, 7], [8, 10], [6, 9]] Output: False ``` At time `6`, both `[2, 7)` and `[6, 9)` are in progress. **Example 3** ```text Input: meetings = [[3, 5], [3, 5]] Output: False ``` The two copies of `[3, 5)` are both in progress at time `3`.

Overview: A coding question that asks whether one person can attend every meeting in a list of half-open time intervals. It tests interval reasoning, correct treatment of back-to-back and duplicate meetings, and an efficient overlap check that scales to a hundred thousand meetings.

ByteDance logo
ByteDance
Oct 16, 2026
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
0
0

A person has a list of meetings, each with a start time and an end time. Return whether they can attend every meeting, which is possible exactly when no two meetings overlap.

Function Signature

def can_attend_all(meetings: list[list[int]]) -> bool:

Rules

  • meetings[i] = [start, end] occupies the half-open interval [start, end) : the meeting is in progress at every time t with start <= t < end .
  • Two meetings overlap when some time t lies in both intervals. A meeting that ends at t and a meeting that starts at t do not overlap.
  • Identical meetings listed twice are separate meetings, and they overlap each other.
  • Return True when there are zero meetings or one meeting.

Constraints

  • 0 <= len(meetings) <= 10^5
  • 0 <= start < end <= 10^9 for every meeting
  • Times are integers, so every value fits in a 32-bit signed integer.
  • meetings is in no particular order.

Examples

Example 1

Input:  meetings = [[9, 12], [1, 4], [4, 9]]
Output: True

In time order the meetings are [1, 4), [4, 9) and [9, 12). Each one starts exactly when the previous one ends, so none overlap.

Example 2

Input:  meetings = [[2, 7], [8, 10], [6, 9]]
Output: False

At time 6, both [2, 7) and [6, 9) are in progress.

Example 3

Input:  meetings = [[3, 5], [3, 5]]
Output: False

The two copies of [3, 5) are both in progress at time 3.