Medium
Reorder a list by alternating front and back nodes.
Reorder the list from L0→L1→…→Ln into L0→Ln→L1→Ln-1→L2→Ln-2… in place.
Examples
Input: head = [1,2,3,4]
Output: [1,4,2,3]
Constraints
- Do not change node values
Coding Challenge
Reorder a list by alternating front and back nodes.
Reorder the list from L0→L1→…→Ln into L0→Ln→L1→Ln-1→L2→Ln-2… in place.
Input: head = [1,2,3,4]
Output: [1,4,2,3]
Preparing your coding workspace...