You are viewing a single comment's thread. Return to all comments →
Python 3
def dynamicArray(n, queries): arr = [[]for _ in range(n)] lastAnswer = 0 result = [] for querie in queries: x = querie[1] y = querie[2] idx = ((x ^ lastAnswer)% n) if (querie[0]==1): arr[idx].append(y) if (querie[0]==2): lastAnswer = arr[idx][y % len(arr[idx])] result.append(lastAnswer) return result
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