Solution close to O(n)


#1

IF there is a rotation just calculate the rotation and do the final sifting for array.

int* rotateArray(int* A, int n1, int B, int *len) {
int *ret = (int *)malloc(n1 * sizeof(int));
*len = n1;
int i, j, count=0;

while( B>n1 )
{
    B = B-n1;
}

for (i = 0; i < (n1-B); i++) 
{
        ret[i] = A[i + B];
        count++;
}
    
for(j=0; j<B; j++ )
{
        ret[i] = A[j];
        i++;
        count++;
}

return ret;

}