Write a method merge_ranges() that takes an array of multiple meeting time ranges and returns an array of condensed ranges.
For example, given: [[0, 1], [3, 5], [4, 8], [10, 12], [9, 10]] Output -> [[0, 1], [3, 8], [9, 12]]
Do not assume the meetings are in order. The meeting times are coming from multiple teams.
Write a solution that's efficient even when we can't put a nice upper bound on the numbers representing our time ranges. Here we've simplified our times down to the number of 30-minute slots past 9:00 am. But we want the method to work even for very large numbers, like Unix timestamps. In any case, the spirit of the challenge is to merge meetings where start_time and end_time don't have an upper bound.
If you want to follow along, feel free to post your answers in the comment.
My answers are in the comments.
This problem is from InterviewCake.