Dsa
Dynamic Programming
Easy
Subset Sum with Constraints
Given a list of integers and an integer target, determine if a subset of the integers can sum up to the target. Additionally, each integer can be used at most once. Implement this using dynamic programming.
Input Format:
- The first line contains an integer n (1 <= n <= 20), the number of integers.
- The second line contains n space-separated integers representing the list.
- The third line contains the target integer.
Output Format:
- Print 'True' if such a subset exists, otherwise print 'False'.
Example:
Input:
5
3 34 4 12 5
9
Output:
True
Key concepts
dynamic_programmingsubset_sumconstraints
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now