Skip to content

Instantly share code, notes, and snippets.

@amorfati0310
Created March 21, 2018 15:59
Show Gist options
  • Save amorfati0310/24e7813c500d6476d0bfeea99d4de30a to your computer and use it in GitHub Desktop.
Save amorfati0310/24e7813c500d6476d0bfeea99d4de30a to your computer and use it in GitHub Desktop.
codility02.js
function solution(A,K) {
// write your code in JavaScript (Node.js 8.9.4)
const length = A.length;
// 1 4
// 2 3
// 3 2
// 4 1
// 5 0
// 6 4
const startIdx = length - (K % length)
const result = A.concat(A).slice(startIdx, startIdx + length);
return result;
}
//n=328=101001000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment