39. Combination Sum

public class Solution {
    public List> combinationSum(int[] candidates, int target) {
        List> res=new ArrayList<>();
        if(candidates.length==0) return res;
        helper(candidates,new ArrayList<>(),target,0,res);
        return res;
    }
    public void helper(int[] candidates,List list, int target,int start,List> res){
        if(target<0) return;
        if(target==0){
            res.add(new ArrayList<>(list));
            return;
        }
        for(int i=start;i

你可能感兴趣的:(39. Combination Sum)