Merge k sorted linked lists into one sorted list. This is a classic problem that combines heaps with linked lists.
Min-heap approach — always grab the smallest available element:
Time: O(N log k) where N = total elements, k = number of lists. The heap never holds more than k elements, so each push/pop is O(log k). This is the technique used in external sorting for massive datasets!
merge_k_sorted([[1,4,5], [1,3,4], [2,6]])
[1, 1, 2, 3, 4, 4, 5, 6]
merge_k_sorted([[], [1]])
[1]