Group all nodes at odd positions (1st, 3rd, …) followed by nodes at even positions, preserving relative order within each group. Solve in O(1) space and O(n) time.
Input: one line of space-separated integers. Output: the regrouped list's values.
1 2 3 4 5
1 3 5 2 4
2 1 3 5 6 4 7
2 3 6 7 1 5 4
Run your code against the sample tests, or Submit to run the full suite.