public static void SubsetsCountTabulation() { var m = new SubsetsCountTabulation(); int[] nums = { 1, 1, 2, 3 }; int count = m.CountOfSubsetsThatCouldSum(nums, 4); Console.WriteLine($"Set 1: Subsets that add up to the sum are {count}\n"); nums = new int[] { 1, 2, 7, 1, 5 }; count = m.CountOfSubsetsThatCouldSum(nums, 8); Console.WriteLine($"Set 2: Subsets that add up to the sum are {count}\n"); }
public int FindTargetSubsets(int[] nums, int targetSum) { // By following logic through lines 10-30 int newSum = (targetSum + nums.Sum()) / 2; SubsetsCountTabulation subsetSum = new SubsetsCountTabulation(); return(subsetSum.CountOfSubsetsThatCouldSum(nums, newSum)); }