Created
December 14, 2017 15:35
-
-
Save harshildarji/bc1e3a6e77e2954668155976d9bae330 to your computer and use it in GitHub Desktop.
Array Rotation (Left and Right)
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
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