LearnPy Hub
← Recursion & Lambda problems
Hard

Subset Sum

Read a list of positive integers and a target. Print Yes if some subset adds up exactly to the target, otherwise No. Use recursion.

Input

A line of integers, then the target.

Output

Yes or No.

Sample 1

Input
3 34 4 12 5 2
9
Output
Yes

Sample 2

Input
3 34 4 12 5 2
30
Output
No
solution.py
Output appears here
Subset Sum · Python practice problem · LearnPy Hub