Subset Sum & Partition
Reach a target with a chosen subset.
The Subset Sum Question
Given numbers and a target, can any subset add up to exactly that target? It is knapsack where value equals weight.
Boolean DP, Not Value
Here you track reachability, not a maximum. Let dp[s] be True when some subset sums to exactly s.
dp = [False] * (target + 1)
dp[0] = TrueAll lessons in this course
- 0/1 Knapsack: Take or Leave
- Space-Optimized Knapsack
- Unbounded & Coin-Change DP
- Subset Sum & Partition