You are viewing a single comment's thread. Return to all comments →
I did it this way, in Java
public static int[] arrayLeftRotation(int[] a, int n, int k) { if (k >= n) { k = k % n; } if (k == 0) return a; int[] temp = new int[n]; for (int i = 0; i < n; i++) { if (i + k < n) { temp[i] = a[i + k]; } else { temp[i] = a[(i + k) - n]; } } return temp; }
Seems like cookies are disabled on this browser, please enable them to open this website
Arrays: Left Rotation
You are viewing a single comment's thread. Return to all comments →
I did it this way, in Java