Skip to content

Commit

Permalink
Adds array left_rotation challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
esl4m committed Jun 2, 2022
1 parent efde468 commit 0a7b0cb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions InterviewPreparationKit/arrays/left_rotation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/python3

def rot_left(a, d):
for i in range(len(a) - 1):
if i < d:
a.append(a[0])
a.pop(0)
return a

if __name__ == '__main__':
# 5 4
# 1 2 3 4 5
nd = [5, 4]
n = int(nd[0])
d = int(nd[1])
a = [1, 2, 3, 4, 5]

print(rot_left(a, d))

# Complete the 'rotLeft' function below.
# The function is expected to return an INTEGER_ARRAY.
# The function accepts following parameters:
# 1. INTEGER_ARRAY a
# 2. INTEGER d

0 comments on commit 0a7b0cb

Please sign in to comment.