Coin Change II (Count Ways)
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given an integer amount representing a target sum of money, and an integer array coins listing the distinct denominations of coins available. You have an **unlimited** supply of every coin denomination.
Return the number of distinct combinations of coins that add up exactly to amount. If no combination can reach the target, return 0.
Two combinations are considered the **same** if they use the same multiset of coins, regardless of the order in which the coins are picked. For example, using [1, 2, 2] is the same combination as [2, 1, 2], so it should only be counted once.
It is guaranteed that the answer fits within a signed 32-bit integer.
Examples
Constraints
- 1 <= coins.length <= 300
- 1 <= coins[i] <= 5000
- All values in `coins` are distinct.
- 0 <= amount <= 5000
- The answer is guaranteed to fit in a signed 32-bit integer.
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.