Loading...
Loading...
Loading...
Move the list to the right by k places. The last k items wrap round to the front. k can be 0 or larger than the list length. Print the rotated list on one line. The starter holds a program with a bug. Find it and fix it.
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.
Only k mod n matters, because n rotations bring the list back.
Cut the list at position n - k and swap the two parts.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor