3.旋转数组(Python)
思路
利用数组切片的思想
参考代码
class Solution:
def rotate(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: void Do not return anything, modify nums in-place instead.
"""
mod = k%len(nums) #移动位数对数组长度取余数
nums[:]=nums[-mod:]+nums[:-mod] #利用数组切片