39 combination sum

 

 

 

1.List<List<Integer>> res= new ArrayList<>();

2. dfs   

    if(target==0) res.add(new ArrayList<Integer>(subset); return;

     if(target>0) return ;

 

     for (int i=index;i< candidates.length;i++){

  subset.add(candidates[i]);

  dfs( candidates, targets-candidates[i], i , res, subset);

   subset.remove(subset.size()-1);

 

posted @ 2022-07-22 07:09  flag!  阅读(30)  评论(0)    收藏  举报