```
right = k % len(nums)
left = len(nums) - right
i = 0
while left > 0 and right != 0:
right_i = len(nums) - right
while right_i < len(nums):
nums[i], nums[right_i] = nums[right_i], nums[i]
right_i += 1
i += 1
if left > right:
left -= right
else:
right = right % left
left = left - right
```