How to solve Subset Sum Problem
We can solve Subset Sum with dynamic programming. Start with sum 0 as achievable (the empty subset). For each array number, add new achievable totals without reusing the same number. Finally, check whether the target is reachable.
Time and space complexity
O(n × target) pseudo-polynomial time and O(target) space.
Practise and improve
Choose JavaScript, TypeScript or Python, complete the starter code, then select Run Tests. Request a hint when you need guidance, or choose View solution and confirm if you would like to study the reference implementation.