from collections import deque def solution(A, K): dq = deque(A) dq.rotate(K) return list(dq)
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]