179. Reverse the First K of a Queue
Reverse only the FIRST k values of the queue, leaving everything after them
in its original order, and print the result from front to back.
So 1 2 3 4 5 with k = 3 becomes 3 2 1 4 5.
Print Invalid if k is larger than the queue.
Constraints - `1 ≤ n ≤ 100000` - `0 ≤ k ≤ 200000` - `-1000000 ≤ value ≤ 1000000`
Input
The first line contains an integer n.
The second line contains n space-separated integers, in queue order from front to back.
The third line contains an integer k.
Output
Print the resulting queue from front to back, n integers on one line, separated by single spaces.
Print Invalid if k is greater than n.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.