diff --git a/algorithms/Java/backtracking/target-sum-subsets.java b/algorithms/Java/backtracking/target-sum-subsets.java new file mode 100644 index 00000000..6a386554 --- /dev/null +++ b/algorithms/Java/backtracking/target-sum-subsets.java @@ -0,0 +1,49 @@ +// Target sum subsets is a program to print all subsets of an array (given by user) such that sum of all elements in subset equal to a target sum given by user + +// Algorithm Type: Backtracking +// Time Complexity: O(2^N) + +import java.io.*; +import java.util.*; + +public class targetSumSubsets { + + public static void main(String[] args) throws Exception { + Scanner scn = new Scanner(System.in); + + // input size of array + int n = scn.nextInt(); + + // input elements of array + int[] arr = new int[n]; + for(int i=0; i