Skip to content

Instantly share code, notes, and snippets.

@SahilKadam
Created October 23, 2016 18:24
Show Gist options
  • Save SahilKadam/1f719d5234062d41cdfa8608221538fb to your computer and use it in GitHub Desktop.
Save SahilKadam/1f719d5234062d41cdfa8608221538fb to your computer and use it in GitHub Desktop.
A left rotation operation on an array of size shifts each of the array's elements unit to the left. For example, if left rotations are performed on array , then the array would become . Given an array of integers and a number, , perform left rotations on the array. Then print the updated array as a single line of space-separated integers.
firstLine = [int(i) for i in input().strip().split(" ")]
secondLine = [int (j) for j in input().strip().split(" ")]
n = firstLine[1]%firstLine[0]
secondLine += secondLine[0:n]
secondLine = secondLine[n:]
[print (i, end = " ") for i in secondLine]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment