from collections import deque
def solution(A, K):
array = deque(A)
array.rotate(K)
return list(array)
def solution(A, K):
# write your code in Python 2.7
if len(A) == 0:
return A
K = K % len(A)
return A[-K:] + A[:-K]
function solution(A, K) {
const rotationNum = (K > A.length) ? (K % A.length) : K;
return rotationNum === 0 ? A : [].concat(A.slice(-rotationNum), A.slice(0, A.length - rotationNum));
}