You are viewing a single comment's thread. Return to all comments →
Simplest one liner in python
for value in (arr[d:] + arr[0:d]): print value,
WHat if d is larger than n?
d is always smaller than or equal to n, see the constraints
Same idea, but if d is an integer with no restrictions, this works:
shifted = a[d%n:] + a[:d%n]
for num in shifted:
print(num, end=' ')
Simply briliiant ;). Thank you!