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.
        """
        # Op1: array slicing
        k = k % len(nums)
        nums[:] = nums[-k:] + nums[:-k]

    def rotate(self, nums, k):
        # Op2 O(1) space
        k = k % len(nums)
        self.reverse(nums, 0, len(nums))
        self.reverse(nums, 0, k)
        self.reverse(nums, k, len(nums))

    def reverse(self, s, begin, end):
        for i in range((end - begin) // 2):
            s[begin + i], s[end - 1 - i] = s[end - 1 - i], s[begin + i]


arr = [1, 2, 3, 4, 5, 6, 7]
test = Solution()
test.rotate([-1], 2)
print(arr)
