Microsoft interview question

Merge K Sorted Linked Lists

Interview Answer

Anonymous

28 Sept 2019

I came up with an algorithm that was pretty slow. Add all the elements of the K lists into an array and then sort the array then create a linked-list of the array. However, he asked for a better optimization. I suggested a priority queue, he said, well implement it. I kinda got stuck there for a bit and then remembered how to use a heap and started coding. I haven't heard back yet.