You are viewing a single comment's thread. Return to all comments →
I did something similar with Python, I imagined it as conveyer belt going back and forth, outcome for mod moves it ahead and q pulls it back...
#!/bin/python3 n, k, q = list(map(int, input().rstrip().split())) arr = list(map(int, input().rstrip().split())) while q: offset = int(input()) - (k%n) if offset < 0: offset += n print(arr[offset]) q -= 1
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 →
I did something similar with Python, I imagined it as conveyer belt going back and forth, outcome for mod moves it ahead and q pulls it back...