Last active
April 24, 2016 06:46
-
-
Save peterschmiz/1623dbd7ac0d3b4faead161f5a90e097 to your computer and use it in GitHub Desktop.
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) { | |
var result = [], | |
i = 0, | |
j = 0; | |
if (A.length === 0) { | |
return A; | |
} | |
if (K > A.length) { | |
K = K % A.length; | |
} | |
for(i; i < K; i++){ | |
result[i] = A[A.length - K + i]; | |
} | |
for(i = K; i < A.length; i++){ | |
result[i] = A[j]; | |
j++; | |
} | |
A = result.slice(); | |
return A; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment