Loading...
Loading...
Loading...
Meeting rooms are booked for time ranges given as start and end hours. Two bookings overlap when they share at least one hour, so 1 to 3 and 3 to 5 overlap. Combine overlapping bookings and print the combined ranges from the earliest start.
Example 1
Input
4 1 3 8 10 2 6 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 the ranges by start first.
A range joins the last combined one when its start is not after that range ends.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor