Search across blog, articles, projects, courses, and community posts
Rotate a list to the right by k positions. Each step moves the last element to the front. Print the rotated list.
Input:
n kn integers.Output: the rotated list, separated by spaces.
1 <= n <= 1000, 0 <= k <= 10^9. k can be larger than n.
5 2 1 2 3 4 5
4 5 1 2 3
3 0 1 2 3
1 2 3