You are viewing a single comment's thread. Return to all comments →
100% tests passes, solution O(q):
static int[] circularArrayRotation(int[] a, int k, int[] queries) { k = k%a.length; int startIndex = (a.length - k)%a.length; int[] out = new int[queries.length]; for (int i = 0; i<queries.length; i++){ out[i] = a[(startIndex + queries[i])%a.length]; } return out; }
Seems like cookies are disabled on this browser, please enable them to open this website
Circular Array Rotation
You are viewing a single comment's thread. Return to all comments →
100% tests passes, solution O(q):