Combination Sum
A medium-tier problem at 75% community acceptance, tagged with Array, Backtracking. Reported in interviews at Airbnb and 27 others.
Combination Sum is a medium backtracking problem that shows up across 28 companies, including Airbnb, Snap, ByteDance, and TikTok. You're given an array of candidates and a target sum, and you need to find all unique combinations that add up to that target. Reusing elements is allowed, which trips up candidates who overthink it as a permutation problem. The 74% acceptance rate masks a real gotcha: the naive approach either double-counts combinations or misses valid ones entirely. If you hit this live and blank on the backtracking structure, StealthCoder solves it invisibly during your assessment.
Companies that ask "Combination Sum"
Combination Sum 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 engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.
Get StealthCoderThe core trick is backtracking with a start index that lets you reuse elements without generating duplicates. Most candidates either iterate from 0 (spawning duplicates like [2, 2, 3] and [2, 3, 2]) or don't allow reuse at all. The correct move is to recurse with the same index when the current candidate still fits the remaining target, and move to the next index only when you backtrack. Your base cases are simple: if the target drops to 0, you found a valid combination; if it goes negative, prune. Array and Backtracking are the only tools you need. Common pitfall: forgetting to check and exclude duplicates in the input array first. If you're solid on recursion and can trace the call stack, this is doable in 15 minutes. StealthCoder is the edge case safety net if the pattern doesn't click during the live OA.
Pattern tags
You know the problem.
Make sure you actually pass it.
Combination Sum 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 engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Combination Sum interview FAQ
Why does my solution count the same combination twice?+
You're iterating from 0 on each recursive call. Start from the current index instead, so [2, 3] and [3, 2] collapse into one. The same element can be reused, but the combination order doesn't matter. Pass index i, not 0, to the next call.
Is Combination Sum still asked at top companies?+
Yes. It's reported by 28 companies across all tiers: Airbnb, TikTok, Oracle, Walmart Labs, and others. The 74% acceptance rate shows it's a classic, but the gotchas around duplicate handling keep it relevant in screening rounds.
What's the difference between this and Combination Sum II?+
In this version, you can reuse elements and the input array has no duplicates. Combination Sum II restricts each element to one use and handles duplicate candidates in the array. If you nail the recursion structure here, II becomes straightforward.
How do I know when to backtrack versus when to prune?+
Prune when target goes negative, return immediately. Backtrack when target hits 0 or no valid path exists. Backtracking means undoing the choice (remove from combination, move to next index), then continuing. Pruning means discarding that entire subtree.
Should I sort the array first?+
Sorting helps prune early: if sorted and the current candidate exceeds the target, all future candidates will too, so you can break. It's not required for correctness, but it cuts runtime on large inputs and shows algorithmic awareness to the interviewer.
Want the actual problem statement? View "Combination Sum" on LeetCode →