MEDIUMasked at 12 companies

3Sum Closest

A medium-tier problem at 47% community acceptance, tagged with Array, Two Pointers, Sorting. Reported in interviews at Bloomberg and 11 others.

Founder's read

3Sum Closest is the problem that shows up when companies want to test whether you actually understand two-pointer logic, not just brute force. Bloomberg, Google, Amazon, Meta, Microsoft, and Uber all ask it. The acceptance rate sits around 47%, which means half the candidates either time out, miss the optimal pointer movement, or miscalculate the distance tracking. You get an array and a target, and you need to find three numbers whose sum is closest to that target. The trap is thinking you need to check every combination. You don't. StealthCoder sits invisibly during your assessment and surfaces the working approach the moment you recognize you need a faster path.

Companies asking
12
Difficulty
MEDIUM
Acceptance
47%

Companies that ask "3Sum Closest"

If this hits your live OA

3Sum Closest is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.

Get StealthCoder
What this means

The trick is sort-then-two-pointers. Sort the array once, then for each element, use left and right pointers to scan the remaining subarray. As you move pointers, track the current sum and calculate its distance from the target. Update your answer whenever you find something closer. The real gotcha is pointer movement: if your current sum is less than the target, move left pointer right to increase it; if it's greater, move right pointer left to decrease it. If it equals the target exactly, you're done. Most candidates either forget to track the minimum distance across iterations, or they move pointers wrong and miss better answers. The topics are Array, Two Pointers, and Sorting. This problem validates you can combine all three without panicking. If you blank on the exact pointer logic during a live OA, StealthCoder runs undetected and delivers a clean, working solution in seconds.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

3Sum Closest recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.

3Sum Closest interview FAQ

Is 3Sum Closest actually asked at FAANG companies, or is it dated?+

It's actively asked. Google, Amazon, Meta, and Microsoft all report this problem. It's not a trick question or filler. They use it to separate candidates who understand algorithmic optimization from those who memorize patterns. The 47% acceptance rate confirms it's neither trivial nor obscure.

What's the trick I'm probably missing?+

You're likely trying to check all triplets (N^3) or not moving pointers correctly. The real pattern: sort once, then for each element, two-pointer scan the rest. The pointer movement is mechanical: sum too small, move left pointer right; sum too large, move right pointer left. Distance tracking is your safety net, not an afterthought.

How does this relate to the original 3Sum problem?+

3Sum finds triplets that sum to zero and deduplicates them. 3Sum Closest finds triplets whose sum is closest to any target, and you don't need to deduplicate because you're returning a single value. Closest is technically simpler because you skip deduplication logic, but the pointer strategy is identical.

Can I solve it without sorting first?+

Not efficiently. Without sorting, you'd need hash-set tricks or brute force, both slower. Sorting is O(N log N). After that, two pointers is O(N^2). Total: O(N^2), which is optimal for this constraint. Trying to avoid the sort wastes time and usually fails the assessment.

What languages is this problem tested in, and does it matter?+

The input data doesn't specify language restrictions. Most assessments allow Python, JavaScript, Java, and C++. Language choice doesn't change the algorithm. Pick whichever you're fastest in. The pointer logic and distance calculation are portable across all of them.

Want the actual problem statement? View "3Sum Closest" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.