```
Stack<int> stack = new Stack<int>();
if (k <= nums.Length)
{
for (int i = nums.Length - 1 - k; i >= 0; i--)
{
stack.Push(nums[i]);
}
for (int i = nums.Length - 1, j = 1; j <= k; j++, i--)
{
stack.Push(nums[i]);
}
int a = 0;
while (stack.Count != 0)
{
nums[a] = stack.Pop();
a++;
}
}
else if(k>nums.Length)
{
k = k-nums.Length;
Rotate(nums,k);
}
```