# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A, K):
# write your code in Python 3.6
if len(A) == 0:
return A
K = K % len(A)
if K <= 0:
return A
# inplace is better
A[:-K] = list(reversed(A[:-K]))
A[-K:] = list(reversed(A[-K:]))
A.reverse()
return A