Skip to content

Commit f893b3d

Browse files
authored
Add new solution for rotate-array.py
1 parent fa6d780 commit f893b3d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Python/rotate-array.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ def rotate(self, nums, k):
8383
break
8484
start += 1
8585

86+
class Solution4:
87+
"""
88+
:type nums: List[int]
89+
:type k: int
90+
:rtype: void Do not return anything, modify nums in-place instead.
91+
"""
92+
def rotate(self, nums, k):
93+
while k > 0:
94+
nums.insert(0, nums.pop())
95+
k -= 1
8696

8797
if __name__ == '__main__':
8898
nums = [1, 2, 3, 4, 5, 6, 7]

0 commit comments

Comments
 (0)