CyclicRotation
by evgkch
JavaScript
const array = [1,2,3,4,5,6,7,8,9];
const CyclicRotation = (A, K) => Array.from(A, (v, i) => (i + K < A.length)
? A[i + K]
: A[i + K - A.length]
)
console.log(CyclicRotation(array, 3))
by evgkch
const array = [1,2,3,4,5,6,7,8,9];
const CyclicRotation = (A, K) => Array.from(A, (v, i) => (i + K < A.length)
? A[i + K]
: A[i + K - A.length]
)
console.log(CyclicRotation(array, 3))