알고리즘

[codility] 풀어보기 - CyclicRotation

Dohoon 2017. 9. 19. 16:49


Lesson 2-2  - CyclicRotation

내용 :

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

시간 복잡도 : no


성공한 코드 : 

function solution(A, K) { // write your code in JavaScript (Node.js 6.4.0) let rt_arr = []; for(i in A) { let idx = (Number(i)+K)%A.length; rt_arr[idx]=A[i]; } return rt_arr; }


결론 :

  • 요건 많이 해보던거라 좀 쉬움
  • 코딜리티 댓글에 배울게 좀 있음