leetcode216

时间:2022-02-21 17:06:02
public class Solution {
public IList<IList<int>> CombinationSum3(int k, int n)
{
int[] num = { , , , , , , , , };
var result = new List<IList<int>>();
helper(result, new List<int>(), num, k, n, );
return result;
} public void helper(List<IList<int>> result, List<int> list, int[] num, int k, int target, int start)
{
if (k == && target == )
{
result.Add(new List<int>(list));
}
else
{
for (int i = start; i < num.Length && target > && k > ; i++)
{
list.Add(num[i]);
helper(result, list, num, k - , target - num[i], i + );
list.RemoveAt(list.Count - );
}
}
}
}

https://leetcode.com/problems/combination-sum-iii/#/description

相关文章