[Javascript/Codility] Lesson2) Array : CyclicRotation
[Codility] Lesson2) Array : CyclicRotation 문제 주어진 배열 A의 요소들을 K만큼 로테이션을 돌린 배열을 반환한다. ex) solution([3, 8, 9, 7, 6], 3) >> [3, 8, 9, 7, 6] -> [6, 3, 8, 9, 7] [6, 3, 8, 9, 7] -> [7, 6, 3, 8, 9] [7, 6, 3, 8, 9] -> [9, 7, 6, 3, 8] 내가 푼 소스코드 function solution(A, K) { let arr = A.length==0 ? [] : A; if (arr.length == K){ return arr; } for (let i = 0; i < K; i++){ let tail = arr.pop(); A.unshift(tail); }..