Reported August 2026
ByteDancehash table

Find Sum Pairs (for mle also :)

Reported by candidates from ByteDance's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live ByteDance OA. Under 2s to a working solution.
Founder's read

ByteDance reported this one in August 2026, and the title even jokes about it being an MLE favorite. Strip the query wrapper and it's a frequency map problem with updates. You've got two arrays, point assignments to a, and count queries for pairs summing to x. If your OA lands in the next day or two, this is the pattern to lock in. StealthCoder is the safety net if you blank mid-assessment, but the idea is short enough to hold in your head.

The problem

You are given two integer arrays, a and b, and an array queries. Process every query in order.
Each query has one of the following forms:
[0, i, x]: assign a[i] the value x.
[1, x]: count the number of pairs of indices i and j such that a[i] + b[j] = x.
Return an integer array containing the results of the [1, x] queries in the order they appear.

Function
findSumPairs(a: int[], b: int[], queries: int[][]) → int[]

Examples
Example 1
a = [3,4]
b = [1,2,3]
queries = [[1,5],[0,0,1],[1,5]]
return = [2,1]
For the first query [1,5], the pairs are a[0] + b[1] = 3 + 2 and a[1] + b[0] = 4 + 1, so the result is 2.
The query [0,0,1] changes a to [1,4]. For the final query, only a[1] + b[0] = 4 + 1 sums to 5, so the result is 1.
Example 2
a = [2,3]
b = [1,2,2]
queries = [[1,4],[0,0,3],[1,5]]
return = [3,4]
Initially, a[0] = 2 pairs with both occurrences of 2 in b, and a[1] = 3 pairs with b[0] = 1, giving 3 pairs that sum to 4.
After assigning a[0] = 3, each of the two values in a pairs with each of the two occurrences of 2 in b, giving 4 pairs that sum to 5.

Constraints
1 <= a.length
1 <= b.length
1 <= queries.length
Every query is either [0, i, x] or [1, x].
Every update index i is valid for a.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The problem reduces to counting. Build a hash map of value to frequency for b once. For a type 1 query, loop over every element of a, and add freq_b[x - a[i]]. That works because b never changes, so its counts stay fixed. For a type 0 query, just overwrite a[i]. No need for a second map unless you want to flip the roles. The common pitfall is rebuilding or scanning b on every query, which turns each count into a nested loop and times out. Another trap is forgetting that duplicates multiply: two 2s in b means a single matching a value contributes 2 pairs, as example 2 shows. Use a default of zero for missing keys, and watch for large counts that may need a wider integer. If you freeze at the live OA, StealthCoder can give you this map-plus-scan solution as a hedge.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Find Sum Pairs (for mle also :) cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as finding pairs with a certain sum. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass ByteDance's OA.

ByteDance reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Sum Pairs (for mle also :) FAQ

What's the trick in this ByteDance Find Sum Pairs problem?+

Count b's values in a hash map once, since b never changes. Then each sum query scans a and adds the count of x minus a[i] from the map. Updates are just array assignments. That avoids any nested loop over both arrays.

How hard is this really?+

Easy to medium. The idea is a standard complement lookup with a frequency map. The difficulty is noticing b is static and handling duplicates correctly. Once you see that, the code is around fifteen lines.

What's the time complexity of the approach?+

Building the map costs O(len b). Each update is O(1). Each sum query costs O(len a). Total is O(len b + q * len a) in the worst case. If a is large and queries are many, you could also map a's frequencies and iterate the smaller one.

What mistakes should I avoid?+

Don't scan b for every query. Don't treat pairs as unique values, since duplicates count separately. Don't forget the missing-key case, which should return 0. Also only append results for type 1 queries, not for updates.

How do I prepare for this in 48 hours?+

Practice complement counting with a hash map, like two sum variants that count pairs. Write this one from scratch once, with both examples as tests. Then rehearse reading the query format carefully, because the two query shapes differ in length and are easy to mix up.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with ByteDance.

OA at ByteDance?
Invisible during screen share
Get it