← Return

Dynamic ArrayEasy

You need to process two types of queries:

  1. Query: \(1 x y\)
    • Compute \(idx = (x \oplus lastAnswer)\).
    • Append the integer \(y\) to \(arr[idx]\).
  2. Query: \(2 x y\)
    • Compute \(idx = (x \oplus lastAnswer)\).
    • Set \(lastAnswer = arr[idx]|y % size(arr[idx])\)
    • Store the new value of \(lastAnswer\) in an answers array.

Notes: