Loading...
Loading...
Loading...
A room has booking requests as start and end times. Merge all bookings that overlap or touch (a booking that starts exactly when the previous one ends). Print the merged bookings in order of start time, one per line as start end. The starter holds a program with a bug. Find it and fix it.
start end per line, ordered by start.Example
Input
3 1 3 2 6 8 10
Output
1 6 8 10
The first two overlap and join into 1 6.
Try the problem first. Open one hint at a time.
Sort the bookings by start time first.
A booking joins the last merged one when its start is at most the last end.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor