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.
lists = [[1,4,5],[1,3,4],[2,6]][1,1,2,3,4,4,5,6]lists = [[1,2],[0,3]][0,1,2,3]poll() the minimum node from the heapnode.next != null, push node.next into the heapdummy.nextWe maintain a min-heap of size ≤ k — one candidate from each list. Each poll() retrieves the globally smallest remaining node in O(log k). After appending it, we push its successor (if any) so each list always has exactly one representative in the heap. Total nodes processed = N, each heap operation costs O(log k), giving O(N log k).