```
class Solution(object):
def rotate(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: void Do not return anything, modify nums in-place instead.
"""
n=len(nums)
if n==1:
return
if k>0:
if k>n:
k=k%n
if k==n or k==0:
return
nums[:k],nums[k:]=nums[-k:],nums[:-k]
return
elif k<0:
k=-k
if k>n:
k=k%n
if k==n or k==0:
return
nums[:-k],nums[-k:]=nums[k:],nums[:k]
```