3Sum Smaller
A medium-tier problem at 51% community acceptance, tagged with Array, Two Pointers, Binary Search. Reported in interviews at PayPal and 1 others.
3Sum Smaller is a trickier cousin of the classic 3Sum, and both PayPal and Google ask it. The acceptance rate sits around 51%, which means half the candidates who attempt it blank or TLE. The problem demands you count triplets with a sum less than a target, not find exact matches. The naive O(n³) scan fails instantly on large arrays. Most candidates know sorting and two pointers but miss the key insight: once sorted, you can eliminate entire ranges at once instead of recalculating. If this problem hits your live OA and you freeze on the optimization, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "3Sum Smaller"
3Sum Smaller 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. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.
Get StealthCoderThe trick is combining sorting with two-pointer traversal, then counting valid triplets in bulk. After sorting, fix one element and run two pointers from left and right. When the triplet sum is too large, you know all pairs to the right of the left pointer also fail, so decrement the right pointer and count the gap. The pattern stops most candidates because they're thinking in terms of finding matches, not rejecting ranges. The algorithm runs in O(n²) time. Common pitfalls include trying binary search (overkill and slower here), getting the counting logic wrong (off-by-one on the gap), or not sorting first and losing the monotonicity property. StealthCoder catches these details instantly if you hit a wall during the assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
3Sum Smaller 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. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.
3Sum Smaller interview FAQ
Is 3Sum Smaller actually asked at FAANG, or is it just LeetCode noise?+
Yes. Both PayPal and Google report it. It's less common than regular 3Sum, but it shows up in phone screens and online assessments. The acceptance rate of roughly 51% suggests it's a real filter, not a warm-up. Expect it if you're going for mid-level roles in backend or data engineering.
What's the difference between 3Sum and 3Sum Smaller algorithmically?+
3Sum finds exact triplets. 3Sum Smaller counts triplets under a threshold. The key difference: once sorted, if a triplet is too large, all triplets with the same left and right pointers but more rightward elements are also too large. You can count entire ranges instead of rechecking each pair. That's where O(n²) lives instead of O(n³).
Why do candidates fail this problem in live OAs?+
Three main reasons: forgetting to sort first (breaks two-pointer logic), miscounting the gap when eliminating ranges (off-by-one errors), or overthinking and reaching for binary search. The two-pointer elimination step is not intuitive without practice. Under OA stress, it's easy to revert to brute force and TLE.
Can I use binary search instead of two pointers?+
Technically yes, but it's slower. Binary search adds a log factor, so O(n² log n) versus O(n²) with two pointers. Interviewers expect the two-pointer solution because it's the textbook approach and it's optimal. Binary search signals you didn't internalize the pattern.
How does this problem relate to sorting and two pointers as topics?+
It's a direct application of both. Sorting establishes the monotonicity property that two pointers exploit. Many array problems use this combo, but 3Sum Smaller forces you to understand why the gap-counting trick works. It's a compressed lesson in how these two topics interact.
Want the actual problem statement? View "3Sum Smaller" on LeetCode →