Last active
July 23, 2017 07:23
-
-
Save MrSimsek/cac5d69d2a707558daf3b9eddeed6ebf to your computer and use it in GitHub Desktop.
Arrays: Left Rotation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def array_left_rotation(a, n, k): | |
# Creta Empty List | |
b = [] | |
# Loop through a | |
for i in range(n): | |
# Append new position value to b | |
b.append(a[(i + k) % n]) | |
return b | |
n, k = 5, 4 # map(int, input().strip().split(' ')) | |
a = [1, 2, 3, 4, 5] # list(map(int, input().strip().split(' '))) | |
answer = array_left_rotation(a, n, k); | |
print(*answer, sep=' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment