dsa1 min read
Perfect Squares — Coin Change with Squares
Minimum perfect squares summing to n. Isomorphic to Coin Change where coins = all perfect squares ≤ n.
Read →
1575 articles
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.
Check if string can be segmented into dictionary words. DP: dp[i]=true if some dp[j] is true and s[j:i] is in wordDict.