use memcpy

class Solution {

public:

void rotate(int nums[], int n, int k) {

int * temp = new int [n];

if(k>n)

k = k%n;

memcpy(temp,nums+n-k,k*sizeof(int));

memcpy(temp+k,nums,(n-k)*sizeof(int));
memcpy(nums,temp,n*sizeof(int));

}

};