Reorder List
Medium
Linked Lists
Linked List
Two Pointers
Stack
Reorder L0→L1→...→Ln to L0→Ln→L1→Ln-1→... Print result.
Constraints
1 ≤ n ≤ 5×10^4
Examples
Example 1:
Input: 1 2 3 4
Output: 1 4 2 3
Example 2:
Input: 1 2 3 4 5
Output: 1 5 2 4 3
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console