Created
July 4, 2019 05:27
-
-
Save icaoberg/599bc7f3db50fe6187055ce38fe371f9 to your computer and use it in GitHub Desktop.
HackerRank - Interview -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
#!/bin/python3 | |
import math | |
import os | |
import random | |
import re | |
import sys | |
# Complete the rotLeft function below. | |
def rotLeft(a, d): | |
for i in range(d): | |
a.append(a.pop(0)) | |
return a | |
if __name__ == '__main__': | |
fptr = open(os.environ['OUTPUT_PATH'], 'w') | |
nd = input().split() | |
n = int(nd[0]) | |
d = int(nd[1]) | |
a = list(map(int, input().rstrip().split())) | |
result = rotLeft(a, d) | |
fptr.write(' '.join(map(str, result))) | |
fptr.write('\n') | |
fptr.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment