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