Loading...
Loading...
Loading...
Bookings are given as start and end hours, in any order. Bookings that overlap or touch must be merged into one. Print the merged bookings in order of start, one per line.
Example 1
Input
4 1 3 2 6 8 10 15 18
Output
1 6 8 10 15 18
Example 2
Input
2 1 4 4 5
Output
1 5
Try the problem first. Open one hint at a time.
Sort by start.
If the next start is at most the last merged end, set the end to the larger of the two ends.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor