Given an array that contains contiguous segments that are sorted, return a sorted array.
Example: [1,3,5,2,4,20,12]
has the following segements: [1,3,5],[2,4,20],[12] which are all sorted
How can we return a sorted array?
I used a heap and then added the first elements of each segment (after calculating the segments). Feel free to share your approach!