Problem
Ask
Submissions

Problem: Reorder List

Medium
30 min
Explore how to reorder a singly linked list by rearranging its node pointers in place. This lesson helps you understand efficient techniques for linked list manipulation that preserve node values while changing structure, enabling you to solve coding interview problems involving in-place operations.

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
Explore how to reorder a singly linked list by rearranging its node pointers in place. This lesson helps you understand efficient techniques for linked list manipulation that preserve node values while changing structure, enabling you to solve coding interview problems involving in-place operations.

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