Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

head =

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

Split the list, reverse the second half, then weave the two halves together.

Approach

  1. Find middle with slow/fast pointers.
  2. Reverse second half.
  3. Merge by alternating nodes from first and reversed second half.

Why it works

The required order is L0, Ln, L1, Ln-1, ..., which is exactly weaving the first half with the reversed second half.

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

Idea

Split the list, reverse the second half, then weave the two halves together.

Approach

  1. Find middle with slow/fast pointers.
  2. Reverse second half.
  3. Merge by alternating nodes from first and reversed second half.

Why it works

The required order is L0, Ln, L1, Ln-1, ..., which is exactly weaving the first half with the reversed second half.

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