Created
October 1, 2017 07:56
-
-
Save johndavedecano/c870be6a24a8fe66101791cfd6ebb405 to your computer and use it in GitHub Desktop.
EXAMS - Cyclic Rotation
This file contains hidden or 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 6.4.0) | |
var TMP = A; | |
for (var i=0; i<K; i++) { | |
var PART = TMP.slice(1, -1); | |
var FIRST = TMP.slice(0, 1); | |
var LAST = TMP.slice(-1); | |
TMP = LAST.concat(FIRST).concat(PART); | |
} | |
return TMP.filter((value, index, self) => self.indexOf(value) === index); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment