THE SUBSET SUM TO TARGET ques

ques link:
https://hack.codingblocks.com/contests/c/512/1086

code link:
https://ide.codingblocks.com/s/44016

I tried using 2-D dp here. Code is working fine except for one test case.
Please guide.

Please guide in the above ques.

Your logic is not correct ,your are adding the all the arrays elements from i+1 till last element
and storing it in two 2-dp . And then comparing if you found sum return true,but what you are missing here ,is what if you found the sum without including the midway elements. Subset doesn’t mean continuous.
for eg :Input = {3, 34, 4, 12, 5, 2}, sum = 9
Output: yes. //There is a subset (4, 5) with sum 9.
in your case it will print NO
I hope this is clear.Try to think differently now.

Thanks a lot for the help

No problem keep coding!