Attend the Most Conference Sessions When Each Takes One Day
Last updated: November 29, 2026
Quick Overview
Each session at a developer conference can be attended on any single day within its inclusive [start, end] range, and you can attend at most one session per day. Return the maximum number of sessions you can attend.
Meta
November 29, 20260
0
0 solved
Each session at a developer conference can be attended on any single day within its inclusive [start, end] range, and you can attend at most one session per day. Return the maximum number of sessions you can attend.
A heap-based greedy in the style of Meta's onsite coding interviews, framed around planning a schedule at a multi-day event like Connect. The interviewer checks that you sweep day by day and always pick the available session that expires soonest, and that you skip idle days efficiently.
What the Interviewer Expects
- Notices that picking by earliest start is wrong
- Sweeps days in order with a min-heap of end days
- Removes sessions that have already expired
- Jumps the day counter forward when the heap is empty
- Justifies the earliest-deadline-first greedy
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- What if sessions have different values and you want maximum total value?
- What if you can attend two sessions per day?
- How would you output the chosen day for each session?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of [start, end] with start <= end, inclusive day numbers up to 10^5. Output: maximum count of sessions attended with at most one per day. Each session counts once....
High-Level Design
Sort sessions by start. Walk day by day. On day d, push the end day of every session starting on d into a min-heap. Discard heap entries whose end < d (missed). If the heap is non-empty, attend the se...