This is my CPP solution.
class Solution {
public:
void rotate(vector<int>& nums, int k) {
int t[100200],n=nums.size();
k = k%n;
for(int i=0;i<n;i++){
if(i>=n-k){
t[i+k-n] = nums[i];
}
else{
t[i+k] = nums[i];
}
}
nums.clear();
for(int i=0;i<n;i++){
nums.push_back(t[i]);
}
}
};