leetcode之Rotate Array

这题就是调换数组。
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.
        """
        for i in range(k):
            nums.insert(0, nums.pop())



你可能感兴趣的:(leetcode之Rotate Array)