Loading...
Loading...
Loading...
A calendar holds non-overlapping bookings sorted by start. A new booking arrives and must be inserted, merging every booking it overlaps or touches. Print the calendar after the insert.
Example 1
Input
2 1 3 6 9 2 5
Output
1 5 6 9
Example 2
Input
5 1 2 3 5 6 7 8 10 12 16 4 8
Output
1 2 3 10 12 16
Try the problem first. Open one hint at a time.
The list is sorted, so no sorting is needed.
Three phases: copy bookings that end before the new one, merge those that touch it, copy the rest.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor