mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
42 lines
1.2 KiB
HTML
42 lines
1.2 KiB
HTML
<p>给定一个可能有重复数字的整数数组 <code>candidates</code> 和一个目标数 <code>target</code> ,找出 <code>candidates</code> 中所有可以使数字和为 <code>target</code> 的组合。</p>
|
|
|
|
<p><code>candidates</code> 中的每个数字在每个组合中只能使用一次,解集不能包含重复的组合。 </p>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>输入:</strong> candidates = <code>[10,1,2,7,6,1,5]</code>, target = <code>8</code>,
|
|
<strong>输出:</strong>
|
|
[
|
|
[1,1,6],
|
|
[1,2,5],
|
|
[1,7],
|
|
[2,6]
|
|
]</pre>
|
|
|
|
<p><strong>示例 2:</strong></p>
|
|
|
|
<pre>
|
|
<strong>输入:</strong> candidates = [2,5,2,1,2], target = 5,
|
|
<strong>输出:</strong>
|
|
[
|
|
[1,2,2],
|
|
[5]
|
|
]</pre>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= candidates.length <= 100</code></li>
|
|
<li><code>1 <= candidates[i] <= 50</code></li>
|
|
<li><code>1 <= target <= 30</code></li>
|
|
</ul>
|
|
|
|
<p> </p>
|
|
|
|
<p><meta charset="UTF-8" />注意:本题与主站 40 题相同: <a href="https://leetcode-cn.com/problems/combination-sum-ii/">https://leetcode-cn.com/problems/combination-sum-ii/</a></p>
|