Created
March 21, 2018 15:59
-
-
Save amorfati0310/24e7813c500d6476d0bfeea99d4de30a to your computer and use it in GitHub Desktop.
codility02.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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