nums[:] = nums[n-k:] + nums[:n-k]
不要用
nums = nums[n-k:] + nums[:n-k]
为什么?
The previous one can truly change the value of old nums, but the following one just changes its reference to a new nums not the value of old nums.
this is the reason
nums[:] = nums[n-k:] + nums[:n-k]
不要用
nums = nums[n-k:] + nums[:n-k]
为什么?
The previous one can truly change the value of old nums, but the following one just changes its reference to a new nums not the value of old nums.
this is the reason