Microsoft Interview Question
Software Engineer / DevelopersTeam: yammer
Country: United States
For any order of numbers in the list, it should support.
I think creating a min heap for the given input and then creating a list by popping the values would give us the proper result.
For n values, creation will take O(n) for min heap. Creating the result array requires popping top element which includes min heap adjustment of O(log n) levels per number. Hence O(n log n)
There can be a more better approach than this. I just gave my thought :)
looks like merging n sorted lists . k-waymerge could solve the problem
- alok.net October 23, 2013