Skip to content

Commit 148c04f

Browse files
Update Arrays: Left Rotation
1 parent debcd47 commit 148c04f

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

Arrays: Left Rotation

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
def array_left_rotation(a, n, k):
2-
for i in range(k):
3-
f = a[0]
4-
a.remove(f)
5-
a.append(f)
6-
return a
7-
1+
def rotLeft(a, d):
2+
return a[d:]+a[:d]
83

9-
n, k = map(int, raw_input().strip().split(' '))
4+
n, d = map(int, raw_input().strip().split(' '))
105
a = map(int, raw_input().strip().split(' '))
11-
answer = array_left_rotation(a, n, k);
6+
answer = array_left_rotation(a, d);
127
print ' '.join(map(str,answer))
138

0 commit comments

Comments
 (0)