Loading...
Loading...
Loading...
Event i can be attended on any day from its start day to its end day, ends included. You can attend at most one event per day. Print the largest number of events you can attend.
Example 1
Input
3 1 2 2 3 3 4
Output
3
Example 2
Input
4 1 2 2 3 3 4 1 2
Output
4
Try the problem first. Open one hint at a time.
On each day, attend the available event that ends soonest.
Sort by start. Use a min-heap of end days. Each day push new events, drop ended ones, and pop one to attend. Jump ahead when the heap is empty.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor