給定乙個陣列candidates
和乙個目標數target
,找出candidates
中所有可以使數字和為target
的組合。
candidates
中的每個數字在每個組合中只能使用一次。
說明:
示例 1:
輸入:candidates =示例 2:[10,1,2,7,6,1,5]
, target =8
,所求解集為:[[1, 7],
[1, 2, 5],
[2, 6],
[1, 1, 6]
]
輸入:candidates = [2,5,2,1,2], target = 5,所求解集為:[[1,2,2],
[5]]
class solution
public boolean find(int candidates, int target,list> res,listtemp,int start)
else
}return true;
}}
組合總和II
給定乙個無重複元素的陣列 candidates 和乙個目標數 target 找出 candidates 中所有可以使數字和為 target 的組合。candidates 中的數字可以無限制重複被選取。說明 所有數字 包括 target 都是正整數。解集不能包含重複的組合。示例 1 輸入 candid...
組合總和 II
給定乙個陣列 candidates 和乙個目標數 target 找出 candidates 中所有可以使數字和為 target 的組合。candidates 中的每個數字在每個組合中只能使用一次。說明 所有數字 包括目標數 都是正整數。解集不能包含重複的組合。示例 1 輸入 candidates 1...
組合總和 II
問題描述 給定乙個陣列 candidates 和乙個目標數 target 找出 candidates 中所有可以使數字和為 target 的組合。candidates 中的每個數字在每個組合中只能使用一次。說明 所有數字 包括目標數 都是正整數。解集不能包含重複的組合。示例 1 輸入 candida...