Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

lists =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Use a min-heap to always pick the smallest head among the k lists.

Approach

Push the head of each non-empty list into a heap keyed by node value. Pop the smallest, append it, then push its next node.

Why it works

The heap maintains the smallest available node across all lists at each step.

Code
Loading...
Complexity
Time: O(N log k)
Space: O(k)
Solution
Updated: 2026-02-23

Idea

Use a min-heap to always pick the smallest head among the k lists.

Approach

Push the head of each non-empty list into a heap keyed by node value. Pop the smallest, append it, then push its next node.

Why it works

The heap maintains the smallest available node across all lists at each step.

Code
Loading...
Complexity
Time: O(N log k)
Space: O(k)