Subset Sum Problem

00:00
MediumDynamic ProgrammingKnapsack
AmazonTCSFlipkart

Determine if there exists a subset of the array that sums to a given target value.

Examples

Input → [3,34,4,12,5,2], target=9
Output → True
Note: 4+5 or 2+3+4
Input → [3,34,4,12,5,2], target=30
Output → False
Input → [1,1,1,1], target=2
Output → True