You are given two integer arrays A and B and a list of operations:
(
-
Query(T): return the number of pairs (i, j) such that A[i] + B[j] = T.
(
-
Replace(idx, val): set B[idx] = val. Return an array containing the result of each Query in order. Example: A = [1, 3], B = [2, 4]; operations: Query
(
5), Replace(0,
3), Query
(
-
-> output [2, 1]. Design a data structure to support very large inputs efficiently and state the time and space complexity of your approach.