143. Reorder List

Description

Given a singly linked list L: L0β†’L1→…→Ln-1β†’Ln, reorder it to: L0β†’Lnβ†’L1β†’Ln-1β†’L2β†’Ln-2→…

You may not modify the values in the list's nodes, only nodes itself may be changed.

Constraints

Approach

Examples

Input: 1->2->3->4

Output: 1->4->2->3

Solutions

Follow up

Last updated