public class Solution
{
public void Rotate(int[] nums, int k)
{
k %= nums.Length;
if (k <= 0  k == nums.Length) return;
Reverse(nums, 0, nums.Length  1);
Reverse(nums, 0, k  1);
Reverse(nums, k, nums.Length  1);
}
private void Reverse(int[] nums, int lower, int upper)
{
int count = (upper  lower) / 2;
for (int i = 0; i <= count; i++)
{
int temp = nums[i + lower];
nums[i + lower] = nums[upper  i];
nums[upper  i] = temp;
}
}
}
Explanation:

Get remainder of
k / nums.Length
to account for cases wherek
is larger thannums.Length
. 
Return if
k
is equal to either zero or the length ofnums
because the rotated array will be unchanged from the original. 
Reverse entire array.

Reverse array from element
0
up tok  1
. 
Reverse array from element
k
tonums.Length  1
;