class Solution: # @param nums, a list of integer # @param k, num of steps # @return nothing, please modify the nums list in-place. def rotate(self, nums, k): k %= len(nums) nums[:] = nums[-k:]+nums[:-k]
s[i:j] = t means slice of s from i to j is replaced by the contents of the iterable t
@tusizi technically the right side is storing temporarily in memory
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.