Medium
Given the head of a singly linked list, group all the nodes at odd positions together followed by the nodes at even positions (1-indexed), preserving relative order within each group. Return the reordered list.
Input: head = [1,2,3,4,5] Output: [1,3,5,2,4]
Input: head = [2,1,3,5,6,4,7] Output: [2,3,6,7,1,5,4]