diff --git a/Solution.java b/Solution.java new file mode 100644 index 0000000..8252a61 --- /dev/null +++ b/Solution.java @@ -0,0 +1,30 @@ + +import java.util.ArrayList; +import java.util.List; + +class Solution { + public static void main(String []args){ + int []nums={2,3,6,7}; + int target=7; + System.out.println(combinationSum(nums,target)); + } + public static List> combinationSum(int[] candidates, int target) { + List>ans=new ArrayList<>(); + generate(candidates,target,0,ans,new ArrayList<>()); + return ans; + } + public static void generate(int []candidates,int target,int i,List>ans,Listal){ + if(target==0){ + ans.add(new ArrayList<>(al)); + return; + } + while(i