You are given an array of k linked lists, each sorted in ascending order. Merge all the lists into one sorted list and return it.
Approach
Use a min - heap (pr iority queue) to always pick the smallest current node across all lists. Push the head of each list into the heap Pop the smallest, append to result, and push its next (if exists)
Recommended resourcesAffiliate links · may earn us a commission
Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books →Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses →Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits →