partition problems - Print all subsets with given sum
Given S = {3,1,1,2,2,1}, a valid solution to the partition problem is the two sets S1 = {1,1,1,2} and S2 = {2,3}. Both sets sum to 5, and they partition S. Note that this solution is not unique. S1 = {3,1,1} and S2 = {2,2,1} is another solution. import java.util.*; public class KNumberSubset { private int number; private int sum; private LinkedList<Integer> subset; private int[] numbers; static LinkedList<LinkedList<Integer>> all=new LinkedList<>(); public KNumberSubset(int[] numbers, int number) { this.numbers = numbers; this.number = number; sum = 0; subset = new LinkedList<Integer>(); } public void findSubset(int startPoint, int limit) { if (sum == number) { //System.out.println(subset + " :: " + sum); all.add((LinkedList<Integer>)subset.clone()); //all.add(subset); } else { for (int i = startPoint; i < numbers.length; i++) { sum = sum + numbers[i]; if (sum > li...