143. Reorder List
Practice Reorder List for free on NudgeCode: Medium, Linked List pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Given a list L0 -> L1 -> ... -> Ln-1 -> Ln, rearrange its nodes into L0 -> Ln -> L1 -> Ln-1 -> L2 -> Ln-2 -> .... Relink the existing nodes in place (don't just change their values) and return nothing.
Example
head = [1,2,3,4,5] -> [1,5,2,4,3]
Constraints
- 1 <= length of the list <= 5 * 10^4
- 1 <= Node.val <= 1000