Concept Flow - Merge K Sorted Lists Using Min Heap
Start with K sorted lists
Create a min heap
Insert first node of each list into min heap
While min heap not empty
Extract min node from heap
Add extracted node to merged list
If extracted node has next, insert next into heap
Repeat until heap empty
Return merged sorted list
We start by putting the first node of each sorted list into a min heap. Then we repeatedly take the smallest node from the heap, add it to the merged list, and if that node has a next node, we add that next node to the heap. This continues until all nodes are merged.
