Using simple swapping , with explanation. 0ms, 100% faster
Click UP ARROW if you like the solution.\nCheck profile if you wanna connect on Twitter\n\nclass Solution {\n    public void rotate(int[] nums, int k) {\n      
Click UP ARROW if you like the solution.\nCheck profile if you wanna connect on Twitter\n```\nclass Solution {\n    public void rotate(int[] nums, int k) {\n        k = k % nums.length;\n        fum(nums, 0, nums.length-1);     //rotating array in [7,6,5,4,3,2,1].\n        fum(nums, 0, k-1);                   //rotating array in [5,6,7,4,3,2,1].\n        fum(nums,k,nums.length-1);     //rotating array in [5,6,7,1,2,3,4].\n    }\n    private void fum(int[] nums, int left , int right){\n        while(left< right){                              // while loop for checking the indexes.\n            int temp = nums[left];                          \n            nums[left] = nums[right];             // simple swapping between array elements.\n            nums[right] = temp;\n            left++;\n            right--;\n        }\n    }\n}\n```
['Java']