Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Linked lists

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Linked lists

Merge K Sorted Lists

advancedlayer B9 · Linked lists5 tests

You are given an array of linked list heads, each list sorted in non-decreasing order. Merge all of them into one sorted list and return its head.

  • The array may be empty, and individual entries may be null
  • Merging them one at a time into an accumulator is O(k*n) — pairing them up is O(n log k)
  • Return null when there is nothing to merge

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen