0023. Merge k Sorted Lists
Hard | Linked List + Sort | 76 ms (98.81%), 22.3 MB (39.22%)
Last updated
Was this helpful?
Hard | Linked List + Sort | 76 ms (98.81%), 22.3 MB (39.22%)
Last updated
Was this helpful?
Source: GitHub:
You are given an array of k
linked-lists lists
, each linked-list is sorted in ascending order.
Merge all the linked-lists into one sorted linked-list and return it.
We could use the "Merge with Divide and Conquer" method for better performance. Generally speaking, we do merge starting with 2 lists per iteration, then increasing to 4 lists per iteration, etc.