Java O(n) in-place solution.
\n    public void rotate(int[] nums, int k) {\n        k %= nums.length;\n        reverse(nums, 0, nums.length-1);  // reverse the whole array\n        reverse(
    \n    public void rotate(int[] nums, int k) {\n        k %= nums.length;\n        reverse(nums, 0, nums.length-1);  // reverse the whole array\n        reverse(nums, 0, k-1);  // reverse the first part\n        reverse(nums, k, nums.length-1);  // reverse the second part\n    }\n    \n    public void reverse(int[] nums, int l, int r) {\n        while (l < r) {\n            int tmp = nums[l];\n            nums[l++] = nums[r];\n            nums[r--] = tmp;\n        }\n    }
['Java']