
You are given two integer arrays:
A
(fixed / primary)
B
(modifiable / secondary)
You must process a sequence of operations of two types:
B[index] = value
.
target
, return the
number of pairs
(i, j)
such that
A[i] + B[j] == target
.
Pairs are counted with multiplicity: if A contains duplicates or B contains duplicates, each index combination counts as a distinct pair.
A
and
B
("update", index, value)
("count", target)
For each ("count", target) operation, output an integer: the number of valid pairs.
A = [1, 2, 2]
B = [3, 2]
target = 4
(1,3)
,
(2,2)
using the first
2
in
A
, and
(2,2)
using the second
2
in
A
→ total
3
.
1 <= len(A), len(B) <= 10^5
10^5