You are viewing a single comment's thread. Return to all comments →
Python 3. Weird-ass exercise, just try to understand what is asked
def dynamicArray(n, queries): arr = [] for i in range(n): arr.append([]) lastAnswer = 0 res = [] for q in queries: x = q[1] y = q[2] idx = ((x^lastAnswer)%n) if q[0] == 1: # query 1 arr[idx].append(y) else: # query 2 lastAnswer = arr[idx][y%len(arr[idx])] res.append(lastAnswer) return res
Seems like cookies are disabled on this browser, please enable them to open this website
Dynamic Array
You are viewing a single comment's thread. Return to all comments →
Python 3. Weird-ass exercise, just try to understand what is asked