Skip to content

Instantly share code, notes, and snippets.

@CreatiCoding
Created September 13, 2018 08:55
Show Gist options
  • Save CreatiCoding/ee1761bba483ff4aa71bee4677631df4 to your computer and use it in GitHub Desktop.
Save CreatiCoding/ee1761bba483ff4aa71bee4677631df4 to your computer and use it in GitHub Desktop.
[codility] CyclicRotation
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
let arr = [];
// write your code in JavaScript (Node.js 8.9.4)
if(A.length === K || K === 0 || A.length === 0){
return A;
}
for(let i = 0 ; i < K ; i ++ ){
let pre = [];
pre[0] = A.pop();
A = pre.concat(A);
}
return A;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment