Skip to content

Instantly share code, notes, and snippets.

@johndavedecano
Created October 1, 2017 07:56
Show Gist options
  • Save johndavedecano/c870be6a24a8fe66101791cfd6ebb405 to your computer and use it in GitHub Desktop.
Save johndavedecano/c870be6a24a8fe66101791cfd6ebb405 to your computer and use it in GitHub Desktop.
EXAMS - Cyclic Rotation
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