```
class Solution {
public:
void rotate(int nums[], int n, int k) {
k = k%n;
int a[k], i;
for (i = 0; i < k; i++) {
a[i] = nums[n-k-i];
}
for (i = n-k-1; i >= 0; i--) {
nums[k+i] = nums[i];
}
for (i = 0; i < k; i++) {
nums[i] = a[i];
}
}
};
```

it says "runtime error"

and my another solution also says runtime error

```
class Solution {
public:
void rotate(int nums[], int n, int k) {
int *a,*b;
k = k%n;
a = nums; b = nums-k;
reverse(a, n-k);
reverse(b, k);
reverse(nums, n);
}
void reverse(int *nums, int n) {
int swap;
for (int i = 0; i < n; i++) {
swap = nums[i];
nums[i] = nums[n-1-i];
nums[n-1-i] = swap;
}
}
};
```

Thanks for helping!