MEDIUMasked at 1 company

Coin Change II

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

Founder's read

Coin Change II is the DP variant that stops tripping up candidates who memorize the greedy approach. It asks how many ways you can make a target amount using unlimited coins of given denominations. Morgan Stanley has asked it. The acceptance rate sits at 62%, which means roughly 4 in 10 candidates miss the combinatorial logic on first attempt. You need to understand why order doesn't matter here, and why a nested loop structure breaks the problem differently than the minimum-coin variant. If this hits your live OA and you blank on the iteration order, StealthCoder solves it in seconds invisible to the proctor.

Companies asking
1
Difficulty
MEDIUM
Acceptance
62%

Companies that ask "Coin Change II"

If this hits your live OA

Coin Change II 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 for the engineer who has done the work but might still blank with a webcam pointed at him.

Get StealthCoder
What this means

The trick is that you're counting combinations, not permutations. Most candidates build a recursive solution with memoization and hit the wall when it's too slow for large coin arrays. The working approach uses a 1D DP array where dp[i] = number of ways to make amount i. The key insight: iterate coins in the outer loop and amounts in the inner loop. This ordering ensures each coin is considered exactly once per amount, eliminating duplicate combinations like (1,2) and (2,1). Many fail because they reverse the loops or confuse this with the unbounded knapsack pattern. The math is straightforward once you see it, but the conceptual leap from recursive thinking to iterative state collapse is where candidates blank. Array and Dynamic Programming are the only tools you need. StealthCoder is your hedge for the one detail that breaks your logic flow during screen share.

Pattern tags

The honest play

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

Coin Change II 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 for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Coin Change II interview FAQ

Is this really harder than Coin Change I?+

Fundamentally different problem. Change I asks for minimum coins, which greedy sometimes solves. Change II asks for count of combinations, which requires DP state logic and careful loop ordering. Change II has a lower success ceiling because the iteration order bug is subtle and easy to miss under time pressure.

What's the most common mistake?+

Reversing the loop nesting. Candidates iterate amounts outer and coins inner, which counts permutations instead of combinations. You'll get wrong answers like 4 ways to make 5 from [1, 2, 5] when the real answer is 2. The outer loop must iterate coins to enforce combination uniqueness.

Why does the 1D DP array work instead of 2D?+

2D is intuitive but wasteful. dp[coin][amount] = ways using coins 0 to coin to make amount. When you process coins in order and update amounts left-to-right, the 1D array naturally holds the previous row. You reuse the same space because you only need the most recent coin's state, not all past coins.

Morgan Stanley asked this. Does that signal anything about the role?+

Morgan Stanley's tech assessments often include classical DP problems. This one tests whether you understand DP state transitions under combinatorial constraints, not just recursion or greedy. Seeing it on their assessment doesn't mean it's uncommon elsewhere, just that it's in their rotation.

How does this relate to the Array and Dynamic Programming topics?+

The array holds coin denominations and is the foundation of your DP state. DP is the entire solution. You build a 1D array where each index represents an amount and each value represents ways to make that amount. The two topics are inseparable here, not separate concerns.

Want the actual problem statement? View "Coin Change II" 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.