문제
풀이
class Solution:
def rotate(self, nums: List[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
k %= len(nums)
nums[:k], nums[k:] = nums[len(nums) - k :], nums[: len(nums) - k]
O(n), O(n) solution