C# solutions
Approach 1: Reverse (preferred)\nIntuition\nMove the last k numbers to the front, and first n-k numbers to the end. But relative order of the two parts won\'t c
**Approach 1: Reverse (preferred)**\n**Intuition**\nMove the last ```k``` numbers to the front, and first ```n-k``` numbers to the end. But relative order of the two parts won\'t change.\n\n\n![image](https://assets.leetcode.com/users/images/ca3ec7f3-6bfe-4c05-bf9a-aeeab79049ae_1631468229.9639452.png)\n\n**Complexity**\n- time: O(n). Each number will be moved twice, O(2n) = O(n).\n- space: O(1)\n\n**Implementation**\n```\npublic class Solution {\n    public void Rotate(int[] nums, int k) {\n        if(nums == null || nums.Length < 2)\n            return;\n        \n        k %= nums.Length;        \n        Reverse(nums, 0, nums.Length - 1);\n        Reverse(nums, 0, k - 1);\n        Reverse(nums, k, nums.Length - 1); \n    }\n    \n    public void Reverse(int[] nums, int left, int right)\n    {\n        while(left < right)\n        {\n            int temp = nums[left];\n            nums[left] = nums[right];\n            nums[right] = temp;\n            left++;\n            right--;\n        }\n    }\n}\n```\n\n</br></br></br>\n**Approach 2: Extra Space**\n**Intuition**\nUse additional space to move ```nums[i]``` to ```arr[(i+k)%n]```\n\n**Complexity**\n* Time: O(n)\n* Space: O(n)\n\n**Implementation**\n```\npublic class Solution {\n    public void Rotate(int[] nums, int k) {\n        \n        if(nums == null || nums.Length == 0 || k == 0)\n            return;\n        \n        int n = nums.Length;\n        int[] tmp = new int[n];\n        for(int i = 0; i < n; i++)\n            tmp[(i + k) % n] = nums[i];\n        \n         for(int i = 0; i < n; i++)\n             nums[i] = tmp[i];\n        \n        // nums = (int[])tmp.Clone(); fail\n        // Array.Copy(tmp, 0, nums, 0, n); success\n        // Array.Copy(tmp, nums, n);       success\n    }\n}\n```\n\n
[]