Skip to content

Commit 66735a3

Browse files
authored
Create Rotate Array.py
1 parent f85e831 commit 66735a3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Python3/Rotate Array.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def rotate(self, nums: List[int], k: int) -> None:
3+
"""
4+
Do not return anything, modify nums in-place instead.
5+
"""
6+
7+
shift = k % len(nums)
8+
for i, n in enumerate([*nums[-shift:], *nums[:-shift]]):
9+
nums[i] = n

0 commit comments

Comments
 (0)