Leetcode 39 Combination Sum
题目原文
Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.
The same repeated number may be chosen from C unlimited number of times.
Note:
- All numbers (including target) will be positive integers.
- The solution set must not contain duplicate combinations.
For example, given candidate set [2, 3, 6, 7]
and target 7
,
A solution set is:
[
[7],
[2, 2, 3]
]
题意分析
给一组候选数据集合以及一个目标,求候选集合中的不同组合,使得每种组合的和等于目标值。候选集合中没有重复的数,每种组合中可以重复选择同一个候选数,同一组合的不同排列算一种组合。
解法分析
五大常用算法思想为分治、贪心、动态规划、回溯、分支界限。本题采用回溯思想,下面先对回溯法进行简要介绍。<