```
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.
"""
# Naive solution - time complexity O(n) space complexity O(n)
# copy = list(nums)
# for i in xrange(len(nums)):
# nums[(i+k)%len(nums)] = copy[i]
# Efficient implementation
# time complexity O(n) space complexity O(1)
n = len(nums)
k = k % n
nums[:n-k] = nums[n-k-1::-1]
nums[n-k:] = nums[n-1:n-k-1:-1]
nums[:] = nums[::-1]
```