Problem: You are given an array of N length. You have to rotate the array rightwards by K rotations, that is, shift each element to the right by K positions. Print the rotated array.
Input: First line contains N and K.
Second line contains N integers denoting the array.
Output: Print the array after the rotation.
Constraints: 1 <= N, K <= 100000
1 <= Arr[i] <= 10^9
Sample Input: 5 2
1 2 3 4 5
Sample Output:
4 5 1 2 3
from collections import deque
k = int(input().split()[1])
a = deque(input().split())
a.rotate(k)
print(' '.join(a))