Given the head of a singly linked list, group all odd-indexed nodes together followed by the even-indexed nodes, and return the reordered list (maintaining original relative order). Indexing is 1-based. Example: Input: head = [1,2,3,4,5] Output: [1,3,5,2,4] Explanation: Nodes at indices 1,3,5 come first, then 2,4. Pattern focus: Pointer Rewiring.
head = ListNode
return ListNode
Example 1:
Input:
head = [1,2,3,4,5]
Output:
[1,3,5,2,4]
Explanation:
Odd indices [1,3,5] then even [2,4].