문제링크

https://app.codility.com/programmers/lessons/2-arrays/cyclic_rotation/

 

CyclicRotation coding task - Learn to Code - Codility

Rotate an array to the right by a given number of steps.

app.codility.com

 

풀이

def solution(A, K):
    temp = 0
    if len(A) == 0:
        return A
    for _ in range(K):
        temp = A.pop()
        A.insert(0, temp)
    return A

첫번째 시도에서 empty array에 대해 지정을 해주지 않아 통과되지 않았다. 배열의 길이가 0일때 그대로 리턴하도록 설정하니 통과됐다.