Skip to content

Latest commit

 

History

History
43 lines (30 loc) · 1 KB

_189. Rotate Array.md

File metadata and controls

43 lines (30 loc) · 1 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 02, 2024

Last updated : July 12, 2024


Related Topics : Array, Math, Two Pointers

Acceptance Rate : 41.74 %


Solutions

Python

# Squarely in the range of [30%, 60%]

class Solution:
    def rotate(self, nums: List[int], k: int) -> None:
        """
        Do not return anything, modify nums in-place instead.
        """

        n = len(nums)
        dequeeuueueueue = deque()
        dequeeuueueueue.extend([nums[(x - k + n) % n] for x in range(0, k)])
        for i in range(n) :
            dequeeuueueueue.append(nums[i])
            nums[i] = dequeeuueueueue.popleft()