Leetcode_Python 189 旋转数组_List

解题思路

思路就这样,额,好吧。。。。。。。。。

代码

class Solution(object):
    def rotate(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: None Do not return anything, modify nums in-place instead.
        """
        i = 0
        k = k % len(nums)
        if nums == []:
            return nums
        while i < k:
            nums.insert(0,nums.pop())
            i += 1
        return nums