You are viewing a single comment's thread. Return to all comments →
If rotate is mandatory:
def circularArrayRotation(arr, rotate, queries): [arr.insert(0, arr.pop()) for _ in range(rotate)] return [arr[i] for i in queries]
If rotate is optional:
def circularArrayRotation(arr, rotate, queries): return [arr[(i - rotate) % len(arr)] for i in queries]
Seems like cookies are disabled on this browser, please enable them to open this website
Circular Array Rotation
You are viewing a single comment's thread. Return to all comments →
Python 3
If rotate is mandatory:
If rotate is optional: