Problem
Ask
Submissions

Problem: Reorder List

Medium
30 min
Understand how to reorder a singly linked list by folding it onto itself through in-place link manipulation. This lesson guides you to solve the problem without modifying node values, optimizing for memory and efficiency. Practice implementing your solution in the coding playground.

Statement

Given the head of a singly linked list, reorder the list as if it were folded on itself. For example, if the list is represented as follows:

L0L_{0}L1L_{1}L2L_{2} → … → Ln2L_{n-2}Ln1L_{n-1}LnL_{n}

This is how you’ll reorder it:

L0L_{0}LnL_{n}L1L_{1}Ln1L_{n - 1}L2L_{2}Ln2L_{n - 2} → …

You don’t need to modify the values in the list’s nodes; only the links between nodes need to be changed.

Constraints:

  • The range of number of nodes in the list is [1,500][1, 500].
  • 5000-5000 \leq Node.value 5000\leq 5000
Problem
Ask
Submissions

Problem: Reorder List

Medium
30 min
Understand how to reorder a singly linked list by folding it onto itself through in-place link manipulation. This lesson guides you to solve the problem without modifying node values, optimizing for memory and efficiency. Practice implementing your solution in the coding playground.

Statement

Given the head of a singly linked list, reorder the list as if it were folded on itself. For example, if the list is represented as follows:

L0L_{0}L1L_{1}L2L_{2} → … → Ln2L_{n-2}Ln1L_{n-1}LnL_{n}

This is how you’ll reorder it:

L0L_{0}LnL_{n}L1L_{1}Ln1L_{n - 1}L2L_{2}Ln2L_{n - 2} → …

You don’t need to modify the values in the list’s nodes; only the links between nodes need to be changed.

Constraints:

  • The range of number of nodes in the list is [1,500][1, 500].
  • 5000-5000 \leq Node.value 5000\leq 5000