A 7-Line Time O(n) In-Place Solution (No Reversing)
The concise 7-line version.\n\n    Sample [1,2,3,4,5,6,7,8,9] 3    \n    The replacing process is as follow:\n    1) 1->4->7->1\n    2) 2->5->8->2\n    3) 3->6-
The concise 7-line version.\n\n    Sample [1,2,3,4,5,6,7,8,9] 3    \n    The replacing process is as follow:\n    1) 1->4->7->1\n    2) 2->5->8->2\n    3) 3->6->9->3\n    public void Rotate(int[] nums, int k) {\n        if(nums.Length == 0 || k % nums.Length == 0) return;\n        int start = 0, i = start, curNum = nums[i], count = 0;\n        while(count++ < nums.Length){\n            int tmp = nums[i = (i + k) % nums.Length];\n            nums[i] = curNum;\n            curNum = i == start ? nums[i = ++start] : tmp;\n        }\n    }\n\n\nBelow is the elaborated version easier to understand\n\n    public void Rotate(int[] nums, int k) {\n        if(nums.Length == 0 || k % nums.Length == 0) return;\n        int start = 0, i = start, curNum = nums[i], count = 0;\n        while(count < nums.Length){\n            i = (i + k) % nums.Length;\n            int tmp = nums[i];\n            nums[i] = curNum;\n            if(i == start){\n                start++;\n                i = start;\n                curNum = nums[i];\n            }\n            else curNum = tmp;\n            count++;\n        }\n    }
[]