dsa1 min read
Coin Change II — Count Ways Unbounded Knapsack
Count number of combinations making up amount. Process each coin denomination completely (outer loop = coin) to avoid counting permutations.
Read →
webcoderspeed.com
1276 articles
Count number of combinations making up amount. Process each coin denomination completely (outer loop = coin) to avoid counting permutations.
Minimum perfect squares summing to n. Isomorphic to Coin Change where coins = all perfect squares ≤ n.
Check if you can reach the last index. Greedy: track furthest reachable index. If current position > reach, stuck.
Find minimum jumps to reach the last index. Greedy: at each jump boundary, extend to the farthest reachable position.
Count ways to decode a digit string as letters (A=1,...,Z=26). DP: single digit + valid double digit transitions.