189. Rotate Array

# python solution 1:
class Solution:
    def rotate(self, nums: List[int], k: int) -> None:
        """
        Do not return anything, modify nums in-place instead.
        """
        for i in range(k):
            s = nums.pop(-1)
            nums.insert(0, s)

Last updated

Was this helpful?