Use a min-heap to always pick the smallest head among the k lists.
Push the head of each non-empty list into a heap keyed by node value. Pop the smallest, append it, then push its next node.
The heap maintains the smallest available node across all lists at each step.
Use a min-heap to always pick the smallest head among the k lists.
Push the head of each non-empty list into a heap keyed by node value. Pop the smallest, append it, then push its next node.
The heap maintains the smallest available node across all lists at each step.