We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 711ecc4 commit 2731ebcCopy full SHA for 2731ebc
Arrays/P02_ArrayRotation.py
@@ -0,0 +1,24 @@
1
+# Author: OMKAR PATHAk
2
+
3
+from Arrays import Array
4
5
+def rotation(rotateBy, myArray):
6
+ for i in range(0, rotateBy):
7
+ rotateOne(myArray)
8
+ return myArray
9
10
+def rotateOne(myArray):
11
+ for i in range(len(myArray) - 1):
12
+ myArray[i], myArray[i + 1] = myArray[i + 1], myArray[i]
13
14
15
+if __name__ == '__main__':
16
+ myArray = Array(10)
17
+ for i in range(len(myArray)):
18
+ myArray.insert(i, i)
19
+ print('Before Rotation:',myArray)
20
+ print('After Rotation:',rotation(3, myArray))
21
22
+ # OUTPUT:
23
+ # Before Rotation: 0 1 2 3 4 5 6 7 8 9
24
+ # After Rotation: 3 4 5 6 7 8 9 0 1 2
0 commit comments