Skip to content

Commit

Permalink
Created simlplified array rotation logic
Browse files Browse the repository at this point in the history
Simplified logic uses slicing of array
  • Loading branch information
dixith authored Oct 14, 2019
1 parent 33f5116 commit 9f0c5d4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions data_structures/array/rotation_simplified.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def rotate(arr, d):
return arr[d:]+arr[:d]

arr = [1,2,3,4,5]
print(rotate(arr, 1))

0 comments on commit 9f0c5d4

Please sign in to comment.