```
class Solution {
public:
void rotate(vector<int>& nums, int k) {
int n = nums.size();
if(nums.empty()||k<0)return;
k%=n;
for(int i = 0;i<k;++i){
nums.insert(nums.begin(),nums.back());
nums.pop_back();
}
return;
}
};
```