[C++] -O(1) space | Simple and easy to understand | O(n) time
Please ask in comments if you face any problem in undestanding.\n\n\nclass Solution {\npublic:\n    void rotate(vector<int>& nums, int k) {\n        int n=nums.
Please ask in comments if you face any problem in undestanding.\n\n```\nclass Solution {\npublic:\n    void rotate(vector<int>& nums, int k) {\n        int n=nums.size();\n        k=k%n;\n        reverse(nums.end()-k,nums.end()); //reverse nums[n-k] to nums[n-1]\n        reverse(nums.begin(),nums.end()-k); //reverse nums[0] to nums[n-k-1]\n        reverse(nums.begin(),nums.end());  //reverse complete array\n    }\n};\n```\n
['Array', 'C', 'C++']