You are viewing a single comment's thread. Return to all comments →
It's XOR operation not Addition.
def dynamicArray(n, queries): lastAnswer = 0 answerList = [] seqLists = [[] for i in range(n)] for i in range(len(queries)): query_type = queries[i][0] x = queries[i][1] y = queries[i][2] if query_type == 1: seq = (x^lastAnswer) % n seqLists[seq].append(y) else: seq = (x^lastAnswer) % n size = len(seqLists[seq]) index = y % size lastAnswer = seqLists[seq][index] answerList.append(lastAnswer) return answerList
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 →
It's XOR operation not Addition.