84. Subset sum equals to target
Given an array arr of n integers and an integer target, determine if there is a subset of the given array with a sum equal to the given target.
Example 1:
Input: arr = [1, 2, 7, 3], target = 6
Output: True
Explanation: There is a subset (1, 2, 3) with sum 6.
Example 2:
Input: arr = [2, 3, 5], target = 6
Output: False
Explanation: There is no subset with sum 6.
Now Your Turn!
Pick the correct output for the given inputInput: arr = [7, 54, 4, 12, 15, 5], target = 9
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= n = 100
- 1<= arr[i] <= 100
- 0<= target <= 5*103