Java solution with O(1) space
public class Solution {\n        public void rotate(int[] nums, int k) {\n            if (nums == null || nums.length == 0) {\n                return;\n        
    public class Solution {\n        public void rotate(int[] nums, int k) {\n            if (nums == null || nums.length == 0) {\n                return;\n            }\n            k = k % nums.length;\n            reverse(nums, 0, nums.length-k-1);\n            reverse(nums, nums.length-k, nums.length-1);\n            reverse(nums, 0, nums.length-1);\n        }\n        private void reverse(int[] num, int left, int right) {\n            while (left < right) {\n                int t = num[left];\n                num[left] = num[right];\n                num[right] = t;\n                left++;\n                right--;\n            }\n        }\n    }
[]