Coding Challenge

Reorder List

Medium
linked-listtwo-pointers

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

Preparing your coding workspace...