Subset sum recursion with c++
<p>This is one of the solution of getting true or false from given set and target value</p>

<pre><code>bool subsetSumExists(Set&lt;int&gt; &amp; set, int target) {
    if (set.isEmpty()) {
        return target == 0;
    } else {
        int element = set.first();
        Set&lt;int&gt; rest = set - element;
        return subsetSumExists(rest, target)
        || (subsetSumExists(rest, target- element));
    }
}
</code></pre>

<p>However, this solution will return true or false value only. How is it possible to get the element that involve in the subset(set that add together will equal to target) as well?</p>

<p>Do I have to use dynamic programming? Coz as i know.. recursion is building up stack actually and after the function return the value, the value inside the frame will be discarded as well.</p>

<p>So, is it possible to get the elements that add up equal to the target value.</p>

<p>Is passing an object a solution of the problem?</p>

<p>Thank you</p>
