```
int tmp[1000001];
void rotate(vector<int> nums, int k) {
int n = nums.size();
k = k%n;
for (int i = 0; i < n - k; i++) {
tmp[i] = nums[i];
// cout << tmp[i];
}
int p = n - k;
for (int i = n - k; i < n; i++) {
nums[i - p] = nums[i];
//cout << i-p<<"----"<<nums[i - p]<<endl;
}
int j = 0;
for (int i = n - 1 - p + 1; i < n; i++) {
nums[i] = tmp[j++];
}
for (int i = 0; i < n; i++) {
cout << nums[i] << " ";
}
cout << endl;
return;
}
```