Java Cyclic Rotation
public class Solution {
public static int[] cyclicRotation(int[] a, int k) {
if (a.length > 0) {
for (int i = 0; i < k; i++) {
int last = a[a.length - 1];
System.arraycopy(a, 0, a, 1, a.length - 1);
a[0] = last;
}
}
return a;
}
}
This rotates the array to the right by K steps and keeps the wrap-around values in the correct order.