JAVA 100% FASTER SOLUION😎😎||STEP BY STEP EXPLAINED
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->O(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->O(1)\n![Screenshot_20230205_171246.png](https://assets.leetcode.com/users/images/2dbd188f-23fb-4f11-a067-e48f48a3a491_1680007896.3123865.png)\n\n\n# Code\n```\nclass Solution {\n\n    public static void reverse(int nums[], int start, int end){\n    // While start index is less than end index\n    while(start < end){\n        // Swap elements at start and end indices\n        int temp = nums[start];\n        nums[start] = nums[end];\n        nums[end] = temp;\n        // Increment start index and decrement end index\n        start++;\n        end--;\n    }\n}\n\n    public void rotate(int[] nums, int k) {\n        // Ensure k is within array bounds\n        k %= nums.length;\n        // Reverse entire array\n        reverse(nums, 0, nums.length - 1);\n        // Reverse first k elements\n        reverse(nums, 0, k - 1);\n        // Reverse remaining elements\n        reverse(nums, k, nums.length - 1);\n    }\n}\n\n```
['Array', 'Java']