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
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

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
Greedy
Heap
Sweep line
Scheduling
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported