The Maximum Number of Events That Can Be Attended coding problem gives you a list of events, each with a start day and end day. You can attend at most one event per day, and you can attend an event on any day within its [start, end] range. Maximize the number of distinct events you attend. Unlike interval scheduling where you attend the full event, here you only need one day per event.
Companies like Uber, Instacart, Microsoft, PayPal, Google, Nvidia, Amazon, and Bloomberg use this problem because it requires a non-obvious greedy with a priority queue. It tests the "earliest deadline first" insight applied to events: each day, attend the event among those currently available that ends soonest. This prevents unnecessarily blocking future events.
Greedy with min-heap by end day: Sort events by start day. Use a min-heap. Iterate over days from 1 to max_end:
This greedy is optimal: always attending the soonest-ending available event maximizes future flexibility.
Events: [[1,2],[2,3],[3,4]]
Events: [[1,4],[4,4],[2,2],[3,4],[1,1]]
For the Array Sorting Heap Priority Queue Greedy interview pattern, the day-by-day simulation with a min-heap is the canonical approach. The pattern: "each day, from all currently eligible items, greedily pick the one expiring soonest." This EDF (Earliest Deadline First) principle underlies dozens of scheduling problems at top tech companies. Master this template and you'll handle an entire class of greedy scheduling questions confidently.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Maximum Subsequence Score | Medium | Solve | |
| Mice and Cheese | Medium | Solve | |
| Put Marbles in Bags | Hard | Solve | |
| Minimum Cost to Hire K Workers | Hard | Solve | |
| IPO | Hard | Solve |