✅Accepted Java code || Beats 100%
Complexity\n- Time complexity : O(n)\n Add your time complexity here, e.g. O(n) \n\n - Space complexity: \n Add your space complexity here, e.g. O(n) \n\n# Java
# Complexity\n- Time complexity : $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n<!-- - Space complexity: -->\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Java\n -- | Details | --\n--- | --- | ---:\n**Runtime** | **0** *ms* | *Beats* **100%**\n**Memory** | **56** *MB* | *Beats* **50%**\n```\nclass Solution {\n    public void rev(int[] nums,int l,int r){\n        while(l<r){\n            // swap\n            nums[l]=nums[l]+nums[r]-(nums[r]=nums[l]);\n            l++;r--;\n        }\n    }\n    public void rotate(int[] nums, int k) {\n        k%=nums.length;\n        rev(nums,0,nums.length-1);\n        rev(nums,0,k-1);\n        rev(nums,k,nums.length-1);\n\n    }\n}\n```\n## UPVOTE : |\n![waiting-tom-and-jerry.gif](https://assets.leetcode.com/users/images/4f0cc754-71e1-4cfc-816b-36a94c20b17f_1678366238.9546802.gif)
['Array', 'Math', 'Two Pointers', 'Java']