Skip to content

Instantly share code, notes, and snippets.

@icaoberg
Created July 4, 2019 05:27
Show Gist options
  • Save icaoberg/599bc7f3db50fe6187055ce38fe371f9 to your computer and use it in GitHub Desktop.
Save icaoberg/599bc7f3db50fe6187055ce38fe371f9 to your computer and use it in GitHub Desktop.
HackerRank - Interview -Arrays - Left Rotation
#!/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