Merge k Sorted Lists
📌 Problem Idea You are given K sorted lists . You want to merge them into one final sorted list . Instead of merging two lists at a time (which can be slow), you use a min-heap to efficiently find the smallest element among all current nodes. ⚙️ Naive Approach Concatenate all lists into one. Sort the combined list. ❌ Time Complexity: O(N log N) (where N = total number of nodes) ✅ Optimized Approach — Using a Min-Heap (Priority Queue) Idea Maintain a min-heap containing the first node (smallest element) from each of the k lists. Repeatedly: Extract the minimum node from the heap. Append it to the result list. Insert the next node from the same list into the heap (if it exists). This way, the smallest available element is always efficiently found in O(log k) time. 🧠 Algorithm Input: k sorted linked lists Output: A single sorted linked list Step...