MEDIUMasked at 1 company

Combination Sum IV

A medium-tier problem at 55% community acceptance, tagged with Array, Dynamic Programming. Reported in interviews at Snap and 0 others.

Founder's read

Combination Sum IV is a medium-difficulty DP problem that catches a lot of people off guard in live assessments because it looks like a straightforward counting problem but requires thinking about order in a way that breaks intuition. Snap has asked it. The acceptance rate is around 55%, which means the people passing it have figured out the right framing, and the people failing it usually tried a greedy or set-based approach that doesn't account for permutations. If you hit this on an OA and the recursive logic isn't clicking, StealthCoder solves it invisibly while you collect yourself.

Companies asking
1
Difficulty
MEDIUM
Acceptance
55%

Companies that ask "Combination Sum IV"

If this hits your live OA

Combination Sum IV 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 StealthCoder
What this means

The trick is recognizing that you're counting ordered combinations, not unordered ones. Most candidates start with a backtracking or subset-generation mindset and get stuck because they're either double-counting or missing valid sequences entirely. The DP solution is clean: for each target sum, iterate through all possible numbers you could use last, and sum the ways to reach the remainder. Memoization or bottom-up DP both work. The pitfall is confusing this with the unbounded knapsack or classic combination sum, where order doesn't matter. Many also struggle with base cases and off-by-one indexing. Since the acceptance rate is just over 50%, this is a genuine sticking point in the assessment. If the pattern isn't drilled into muscle memory and you blank under time pressure, StealthCoder delivers a working solution in seconds, keeping you moving on the rest of the test.

Pattern tags

The honest play

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

Combination Sum IV 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 IV interview FAQ

Why is the greedy approach wrong here?+

Greedy doesn't work because order matters. With target 4 and candidates [1,2,3], sequences [1,3] and [3,1] are different. Greedy picks the largest coin first and misses combinations that depend on smaller choices early. You need DP to count all valid orderings exhaustively.

How does this differ from the classic Combination Sum problem?+

Classic Combination Sum finds specific subsets (unordered) and prevents reuse via recursion depth. Combination Sum IV counts all permutations (ordered) of unlimited numbers. The DP recurrence counts ways, not subsets. If you've only practiced the backtracking version, the mental model is different.

Is Combination Sum IV still asked by top companies?+

Snap has explicitly asked it. At 55% acceptance, it's a genuine filter. It's not as flashy as graph or string problems, so it shows up less in public reports, but DP fundamentals like this remain interview staples across most tech companies.

What's the time complexity and why does it matter?+

O(n * target) for both time and space, where n is the candidate count. This is polynomial and fast enough for reasonable input ranges. The key is that memoization or tabulation both fit comfortably. No tricks needed on optimization, just correct DP logic.

What do I do if I freeze on the recurrence during the OA?+

Think bottom-up: for each sum from 1 to target, count how many ways you can reach it by trying every candidate as the last step. Write the loop structure first, debug the base case, then verify with a small example. If you still blank, StealthCoder gives you a working template instantly.

Want the actual problem statement? View "Combination Sum IV" 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.