title: find all subsets that sum to x - using an initial code
body: <p>I am trying to build upon a problem, to solve another similar problem... given below is a code for finding the total number of subsets that sum to a particular value, and I am trying to modify the code so that I can return all subsets that sum to that value (instead of finding the count).</p>
  
  <p>Code for finding the total number of suibsets that sum to 'sum':</p>
  
  <pre><code> /**
   * method to return number of sets with a given sum.
   **/
  public static int count = 0;
  public static void countSubsetSum2(int arr[], int k, int sum) {
      if(sum == 0) {
          count++;
          return;
      }
      if(sum != 0 &amp;&amp; k == 0) {
          return;
      }
      if(sum &lt; arr[k - 1]) {
          countSubsetSum2(arr, k-1, sum);
      }
      countSubsetSum2(arr, k-1, sum - arr[k-1]);
      countSubsetSum2(arr, k-1, sum);
  }
  </code></pre>
  
  <p>Can someone propose some changes to this code, to make it return the subsets rather than the subset count?</p>