Rotate Array
class Solution { public: void rotate(int nums[], int n, int k) { k%=n; reverse(nums,0,n-k-1); reverse(nums,n-k,n-1); reverse(nums,0,n-1); } void reverse(int nums[],int first,int end){ int i=first,j=end; for(;i<j;i++,j--){ nums[i]^=nums[j]; nums[j]^=nums[i]; nums[i]^=nums[j]; } } };