372. Odd-Even Linked List
MediumLinked List
Group nodes at odd positions (1st, 3rd, …) followed by nodes at even positions, keeping their order. Print the list.
Input format
Line 1: n Line 2: n values
Output format
The regrouped list.
Example 1
Input
5 1 2 3 4 5
Output
1 3 5 2 4
Example 2
Input
6 2 1 3 5 6 4
Output
2 3 6 1 5 4
Constraints
1 ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…