Skip to content

Instantly share code, notes, and snippets.

@harshildarji
Created December 14, 2017 15:35
Show Gist options
  • Save harshildarji/bc1e3a6e77e2954668155976d9bae330 to your computer and use it in GitHub Desktop.
Save harshildarji/bc1e3a6e77e2954668155976d9bae330 to your computer and use it in GitHub Desktop.
Array Rotation (Left and Right)
n, d = map(int, input().split()) # n = len(array), d = Number of rotation
values = [i for i in input().split()][:n]
print(" ".join(values[d:] + values[:d])) # left rotation
print(" ".join(values[n-d:] + values[:n-d])) # right rotation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment