Rotate Array
Medium 40 XPArrays
Commonly asked at Amazon, Microsoft
Read a list of integers and k. Rotate the list to the right by k steps and print it. k may be larger than the list length.
- Input
- Line 1: space-separated integers. Line 2: k (k ≥ 0).
- Output
- The rotated list, space-separated.
Sample 1
Input
1 2 3 4 5 6 7 3
Output
5 6 7 1 2 3 4
Read input with input() (no prompt message) and print only the answer. Run tries the Input box; Submit checks all test cases.
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.The solution unlocks after 3 submissions.