Loading...
Loading...
Loading...
A hall receives booking requests with a start and an end hour. Two bookings may share an end and a start hour. Print the largest number of bookings that can be accepted without any overlap.
Example 1
Input
6 1 4 3 5 0 6 5 7 3 9 8 11
Output
3
Example 2
Input
3 1 5 4 6 5 9
Output
2
Try the problem first. Open one hint at a time.
Sorting by start or by length can be fooled; look for a counterexample.
Sort by end time and take every request that starts at or after the last chosen end.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor