#328 - Odd Even Linked List
Given the head of a singly linked list, group all nodes at odd indices together followed by all nodes at even indices (1-indexed). The relative order inside each group must stay the same. Must use O(1) extra space and O(n) time.
| Input | Output |
|---|---|
[1,2,3,4,5] | [1,3,5,2,4] |
[2,1,3,5,6,4,7] | [2,3,6,7,1,5,4] |