4 python solutions
Delete k elements from the end and insert them at the begining\npython\nclass Solution(object):\n    def rotate(self, nums, k):\n        for i in range(k % len(
Delete k elements from the end and insert them at the begining\n```python\nclass Solution(object):\n    def rotate(self, nums, k):\n        for i in range(k % len(nums)):\n            nums.insert(0, nums.pop())\n```\n\nIteratively move each element to it\'s correct position\n```python\nclass Solution(object):\n    def rotate(self, nums, k):\n        k = k % len(nums)\n        n = len(nums)\n        i = 0\n        count = 0\n        while count < n:\n            pos = (i + k) % len(nums)\n            curr = nums[pos]\n            nums[pos] = nums[i]\n            count += 1\n            j = pos\n            while j != i and count < n:\n                pos = (j + k) % len(nums)\n                nums[pos], curr = curr, nums[pos]\n                j = pos\n                count += 1\n            i += 1\n```\n\nUse an additional array to copy the elements into rotated positions and copy them back to original array\n```python\nclass Solution(object):\n    def rotate(self, nums, k):\n        k = k % len(nums)\n        dupnums = [0] * len(nums)\n        for i in range(len(nums)):\n            dupnums[(i + k) % len(nums)] = nums[i]\n\n        nums[:] = dupnums # copy dupnums to nums\n```\n\nSame as the first one. But, by taking advantage of python\'s list indexing.\n```python\nclass Solution(object):\n    def rotate(self, nums, k):\n        k = k % len(nums)\n        nums[:] = nums[-k:] + nums[:-k]\n```
[]