• + 1 comment

    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;
        }