Given the head of a singly linked list, reorder it to be on the form: L0 -> Ln -> L1 -> Ln-1 -> L2 -> Ln-2 -> .... You may not modify node values, only the nodes themselves.
Input: values = [1,2,3,4]
Output: [1,4,2,3]
Topics: linked-list, two-pointers
Asked by: Amazon, Meta, Microsoft
Time complexity: O(n). Space complexity: O(1).