FastPrepDynamic Pair Sum Queries
Problems/Dynamic Pair Sum Queries

Dynamic Pair Sum Queries

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Five ZipRecruiter new-grad OA reports describe a fixed array, a mutable array, additive point updates, and counting pairs across the arrays that reach a target sum. The oldest linked report supports the same kind of query. The reports call the mutable array b, while our version shows it first as a. They leave out full limits and reusable image data.

The array that gets updated is the first parameter, a.

You are given two integer arrays a and b and a sequence of queries. Process the queries in order.

  • A query [0, i, x] adds x to a[i].
  • A query [1, x] asks for the number of index pairs (i, j) such that the current values satisfy a[i] + b[j] = x.

Return the answers to all type-1 queries in their original order.

Function

processPairSumQueries(a: int[], b: int[], queries: int[][]) → long[]

Examples

Example 1

a = [1,4]b = [1,2,3]queries = [[1,5],[0,0,2],[1,5]]return = [1,2]

Before the update, only a[1] + b[0] = 4 + 1 = 5, so the first answer is 1. The update changes a[0] from 1 to 3. Then both 3 + 2 and 4 + 1 equal 5, so the second answer is 2.

Constraints

  • a, b, and queries are non-empty.
  • Every type-0 query has the form [0, i, x] with 0 <= i < a.length.
  • Every type-1 query has the form [1, x].
  • Array b is never modified.

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN
  • Count Overlapping Square PairsRamp · OARamp interview questions
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Count Suffix Word PairsTikTok · OATikTok interview questions
  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
  • Find Valid SET Card TriplesSnowflake · OA · PHONE SCREENSnowflake interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public long[] processPairSumQueries(int[] a, int[] b, int[][] queries) {
        // write your code here
    }
}
Checking account…