The algorithm is O(n) time, O(1) space

It has 3 steps:

- reverse nums from 0 to n-1;
- reverse nums from 0 to k-1;
- reverse nums from k to n-1;

code:

```
class Solution {
public:
void rotate(int nums[], int n, int k) {
k %= n;
reverse(nums, nums + n);
reverse(nums, nums + k);
reverse(nums + k, nums + n);
}
};
```