array1 [Python] 2.1. CyclicRotation https://app.codility.com/programmers/lessons/2-arrays/ 2. Arrays lesson - Learn to Code - Codility Rotate an array to the right by a given number of steps. app.codility.com 빈 배열이 들어올 경우에는 그대로 리턴한다 빈 배열이 아닌 경우 입력값 K에 대한 나머지를 구하고 다음 인덱스 값을 계산해준다 만약 다음 인덱스 값이 음수 일 경우, 배열의 크기를 더해서 인덱스 값을 보정해준다. def solution(A, K): if len(A) == 0: return A rotate = K % len(A) answer = [] for idx in range(len(A)): nex.. 2021. 3. 6. 이전 1 다음 728x90 반응형