The link to the question is as follows:
https://www.geeksforgeeks.org/dynamic-programming-subset-sum-problem/
I do not see the overlapping subproblem property being fulfilled in the question atleast for ever input case.
For instance in the follwing link, the recursive tree does not have any overlapping subproblem
http://www.zrzahid.com/subset-sum-problem-dynamic-programming/
Also, for instance in the following program there are no overlapping subproblems. I do not understand how dynamic programming helps here, when there are no overlapping subproblems. Please explain.
bool isSubsetSum(int set[],int n, int sum)
{
if(sum==0)
return true;
if(n==0 || sum<0)
return false;
return isSubsetSum(set,n-1,sum-set[n-1]) || isSubsetSum(set,n-1,sum);
}
int main()
{
int set[] = {3, 34, 4, 12, 5, 2};
int sum = 9;
int n = sizeof(set)/sizeof(set[0]);
if (isSubsetSum(set, n, sum) == true)
printf("Found a subset with given sum");
else
printf("No subset with given sum");
return 0;
}