Loading...
Loading...
Loading...
Staff names rotate through shifts. Move the last k items to the front, keeping their order. k can be bigger than n; rotating by n gives the same list back.
Example
Input
5 2 1 2 3 4 5
Output
4 5 1 2 3
The last two items, 4 and 5, move to the front.
Try the problem first. Open one hint at a time.
Reduce k with the remainder after division by n so a full turn does nothing.
The answer is the last k items followed by the rest. Take care when k is 0.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor