Simple solution in C


#1

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

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

for (j=0; j < B; j++,i++) {
    ret[i] = A[j];
}
return ret;

}