Back to problems

Dynamic Two-Array Pair Sum Queries

Algorithm · Capital One · Medium

Requirements You receive arrays a and b together with a sequence of queries that must be handled in order. A query shaped [0, x] asks for the number of pairs formed by choosing one value from a and one from b whose total equals x; add that number to the result list. A query [1, z, y] replaces the value at a[z] with y. Produce the list containing the answers from every type-0 query. Duplicate values are counted by position: matching values located at separate indices…

Checking your access…