Most Meetings You Can Attend When Each Takes One Day Within Its Range
Company: Snowflake
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: Each meeting can be attended on any single day within its range, and only one meeting fits on each day; return the largest number of meetings you can attend. It tests interval scheduling reasoning and an exchange argument for why a local choice stays optimal.
Constraints
- 1 <= len(meetings) <= 10^5
- meetings[i] = [start, end] with 1 <= start <= end <= 10^5 for every meeting; both ends are inclusive
- Each meeting counts at most once and each day can be used for at most one meeting
- No value can exceed 2^31 - 1: every day and the answer fit in a 32-bit signed integer
Examples
Input: ([[1, 1]],)
Expected Output: 1
Explanation: Minimum valid input: a single one-day meeting is attended; an exclusive-end reading would return 0.
Input: ([[2, 3], [1, 2], [1, 2], [3, 4]],)
Expected Output: 4
Explanation: Source Example 1: unsorted input with a duplicate pair; the meetings take days 1, 2, 3 and 4.
Hints
- Example 3 shows a capacity limit: when more meetings than days fall inside the same window, some of them must be skipped no matter how the rest are scheduled.
- When several meetings could use the same day, ask which choice keeps the most options open for the meetings that are still unscheduled.
- Both ends of a window are usable days, and identical [start, end] pairs are separate meetings that compete for the same days.