Skip to main content
All Questions

Merge k sorted linked lists.

Hard

Merge K Sorted Linked Lists. You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Your task is to merge all the linked-lists into one sorted linked-list and return it.

Examples:

  1. If lists = [[1,4,5],[1,3,4],[2,6]], where each array represents a linked-list, the merged and sorted linked-list would be [1,1,2,3,4,4,5,6]. The output for the merged list should be in array form for simplicity.
  2. If lists = [], indicating an array of no linked-lists, the output should be [].
  3. If lists = [[]], representing an array with a single empty linked-list, the output should be [].
  4. If lists = [[],[1]], where the first linked-list is empty and the second contains a single element, the output should be [1].
  5. If lists = [[-1,5,11],[],[6,10]], the merged and sorted linked-list should be [-1,5,6,10,11].

Constraints:

  • k == lists.length
  • 0 <= k <= 10^4
  • 0 <= lists[i].length <= 500
  • 10^4 <= lists[i][j] <= 10^4
  • lists[i] is sorted in an increasing order.

Interview experiences

6 shared
Revolut · 2 months ago
"Its good, but I was bad and dont really remember much. But all rounds was good. HR was nice. Tech guy on tech interview was nice too."
Software Engineer · Entry Level / L3
F
FloQast · 2 months ago
"Screening and the system design with director are virtual, while on-site loop in the office. The process is well organized and the recruiter provided great instructions on how to find the office. Office loop was completely on whiteboard, while the last interview was on zoom from the same meeting room."
Software Engineer · Senior / L5
Amazon · 5 months ago
"My interview panel was for a specific team and not a general hiring pipeline. 3 rounds technical + behavioral. First 20 mins behavioral then technical. Last round was bar raiser. Everything went good for me, few questions were new like "experience with gen ai", rest everything was traditional LC + LP based behavioral."
Software Engineer
Intuit · 2 years ago
"Pretty easy leetcode. The final round is just a few hours to implement an app. Not too difficult if you are comfortable creating an app."
Software Engineer · Senior / L5
Meta · 2 years ago
"It mostly went well. I was thrown off by the fact that a lot of the focus in the system design rounds was on the product and UX side, only to discover it was product architecture later and that there had been a miscommunication."
Software Engineer · Senior / L5
Meta · 3 years ago
"The process was what was expected and they were quick in scheduling and re-scheduling as needed. All questions were ones I had seen before via LC tagged."
Software Engineer · Entry Level / L3

Related courses

Course

Machine Learning Engineer Interview Prep

Land your dream machine learning role at Meta, Google, Amazon, Apple, Microsoft, Nvidia, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Explore ML system design, core concepts, coding, behavioral interviews, and more.

Course

Data Science Interview Prep

Land your dream data science role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Practice statistics, experimentation, coding, SQL, machine learning, behavioral interviews, and more.