147. Reverse in Groups of K
Reverse the list in groups of k nodes and print the result.
So 1 2 3 4 5 with k = 2 becomes 2 1 4 3 5. A final group with fewer than k nodes is
reversed as well.
Print Empty for an empty list.
Constraints - `0 ≤ n ≤ 100000` - `1 ≤ k ≤ 100000` - `-1000000 ≤ value ≤ 1000000`
Input
The first line contains an integer n, the number of nodes.
The second line contains n space-separated integers — the node values from head to tail.
The starter code builds the list for you; work on the nodes, not the array.
The third line contains an integer k — the group size.
Output
Print the resulting list from head to tail on ONE line, separated by single spaces, or Empty if no nodes remain.
Hints
Four rungs, in order. The last two open once you have submitted an attempt — a wrong one counts.