Given a singly linked list, group all nodes at odd positions together followed by the nodes at even positions, preserving the relative order within each group. Positions are 1-indexed (the first node is odd). The list is given as an array; return the rearranged array.
Input: An array of node values.
Output: Array — odd-position nodes then even-position nodes.
Input: [1,2,3,4,5]
Output: [1,3,5,2,4]
Explanation: Odd positions 1,3,5 then even 2,4.Input: [2,1,3,5,6,4,7]
Output: [2,3,6,7,1,5,4]
Explanation: Grouped by position parity.Input: [1]
Output: [1]
Explanation: Single node.0<=n<=10^4-10^6<=value<=10^6