Skip to content

Commit 438d97f

Browse files
committed
Add array rotation
1 parent 0f8aa03 commit 438d97f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

data_structures/array/rotation.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def rotate(arr, d):
1111
for i in range(g):
1212
temp = arr[i]
1313
j = i
14-
1514
while 1:
1615
k = j + d
1716
if k >= n:
@@ -20,5 +19,9 @@ def rotate(arr, d):
2019
break
2120
arr[j] = arr[k]
2221
j = k
23-
2422
arr[j] = temp
23+
24+
25+
arr = [1,2,3,4,5,6]
26+
rotate(arr, 1)
27+
print(arr)

0 commit comments

Comments
 (0)