```
class Solution {
public:
void rotate(vector<int>& nums, int k) {
int n = nums.size();
vector<int> res(nums.begin() + n - k % n, nums.end());
for(int i = 0; i < n - k % n; i++) res.push_back(nums[i]);
swap(res, nums);
}
};
```