Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

list1 =
list2 =

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

Merge like the merge step of merge sort using two pointers.

Approach

Walk both lists, always attaching the smaller node to the result list. Append the remainder when one list ends.

Why it works

At each step, the smallest remaining node must be the head of one of the two lists.

Code
Loading...
Complexity
Time: O(n+m)
Space: O(1)
Solution
Updated: 2026-02-23

Idea

Merge like the merge step of merge sort using two pointers.

Approach

Walk both lists, always attaching the smaller node to the result list. Append the remainder when one list ends.

Why it works

At each step, the smallest remaining node must be the head of one of the two lists.

Code
Loading...
Complexity
Time: O(n+m)
Space: O(1)