23. Merge k Sorted Lists
Practice Merge k Sorted Lists for free on NudgeCode: Hard, Linked List pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
You are given an array of k linked lists, each sorted in ascending order. Merge them all into one sorted linked list and return its head.
Example
lists = [[1,4,5],[1,3,4],[2,6]] -> [1,1,2,3,4,4,5,6]
Constraints
- 0 <= k <= 10^4
- 0 <= length of each list <= 500
- -10^4 <= Node.val <= 10^4
- the total number of nodes is at most 10^4