94. Combinations That Sum to the Target
Medium
Given distinct positive candidates and an alvo. Return the combinations whose sum is the target. A candidate may appear more than once in a combination; the order of the groups and of the values inside them does not matter.
Example 1
Input: candidatos = [2, 3, 6, 7], alvo = 7
Output: [[2, 2, 3], [7]]
Example 2
Input: candidatos = [2, 4], alvo = 3
Output: []
Constraints
- 1 <= candidatos.length <= 10
- 1 <= candidatos[i] <= 30
- 0 <= alvo <= 40
- Os candidatos são distintos.
BacktrackingArrays
Saved in this browser
Caso 1
candidatos =
[2,3,6,7]
alvo =
7
Expected =
[[2,2,3],[7]]
Caso 2
candidatos =
[2,4]
alvo =
3
Expected =
[]
Run checks these 2 cases. Submit runs all 6, including hidden ones.