diff --git a/TargetSumSubsets.java b/TargetSumSubsets.java new file mode 100644 index 0000000..29fc889 --- /dev/null +++ b/TargetSumSubsets.java @@ -0,0 +1,38 @@ +import java.io.*; +import java.util.*; + +public class Main { + + public static void main(String[] args) throws Exception { + Scanner scn = new Scanner(System.in); + int n = scn.nextInt(); + int[] arr =new int[n]; + for(int i=0;itar){ + return; + } + if(idx==arr.length){ + if(sos==tar){ + System.out.println(set + "."); + + }return; + } + + printTargetSumSubsets( arr, idx+1, set + arr[idx]+", ", sos+ arr[idx], tar); + printTargetSumSubsets(arr, idx+1, set, sos, tar); + + } + +}