HHubSpot·DSASWE-2Technical Phone Screen
Merge K Sorted Lists
Problem
Merge k sorted linked lists into one sorted list.
Example
[[1,4,5],[1,3,4],[2,6]] -> [1,1,2,3,4,4,5,6]
Constraints
- 0 ≤ k ≤ 10^4
Approach
Min-heap of heads -> O(N log k). Common HubSpot question.
added 6 days ago