Given the head of a singly linked list, reorder it such that the nodes in the list are arranged in an alternating left-to-right and right-to-left manner, while keeping the original relative order of the nodes.
The input to the problem is the head of a singly linked list, and the output is the modified linked list with the nodes reordered according to the problem statement.
Input: {"head":[1,2,3,4]} Output: [1,4,2,3]
Solve problems, verify your skills, and earn XP.