見出し画像

189. Rotate Array / LeetCode

Description

画像1

画像2

Submission

class Solution:
	def rotate(self, nums: List[int], k: int) -> None:
		length = len(nums)
		rotated = [0] * length
		for index in range(length):
			rotated[(index + k) % length] = nums[index]
		for index in range(length):
			nums[index] = rotated[index]

いいなと思ったら応援しよう!