LeetCode 143 Reorder List - Problem Statement

The problem

Given the head of a singly linked list L0 → L1 → ... → Ln-1 → Ln, reorder it to L0 → Ln → L1 → Ln-1 → L2 → Ln-2 → ...

With 1 → 2 → 3 → 4, the answer is 1 → 4 → 2 → 3. You interleave from the front and back.

With 1 → 2 → 3 → 4 → 5, the answer is 1 → 5 → 2 → 4 → 3. The middle element stays in place.

You must do this in-place without modifying node values.

Constraints: 0n5×1040 \le n \le 5 \times 10^4.