• + 1 comment

    exactly my point also is the same. no use of rotation further when orginal array and rotated array are same. Could you tell me whether logic will work ?

    static int[] circularArrayRotation(int[] a, int k, int[] queries) { int[] rotationArray = new int[a.Length]; int[] result = new int[queries.Length]; int rotationStartIndex = (a.Length - k); int rotationStopIndex = (a.Length - k) - 1; int index = 0; while (rotationStartIndex <= a.Length -1) { rotationArray[index] = a[rotationStartIndex]; index++; rotationStartIndex++; } rotationStartIndex = index; index = 0; while (index <= rotationStopIndex) { rotationArray[rotationStartIndex] = a[index]; index++; rotationStartIndex++; }

            for (int i = 0; i < queries.Length; i++)
            {
                if (queries[i] < result.Length)
                {
                    result[i] = rotationArray[queries[i]];
                }
            }
            return result;
    
        }