您将如何测试一组给定数字的所有可能的添加组合,以便它们加起来给定的最终数字?
例:
language-agnostic algorithm search combinations subset-sum
假设我有一个列表:
List<int> _arr = new List<int> {1, 3, 4};
而且是一个目标 4
4
我想回到{1, 3}作为1 + 3 = 4和{4}作为4 = 4使用LINQ从给定的列表.
{1, 3}
1 + 3 = 4
{4}
4 = 4
我怎么做?
c# linq
algorithm ×1
c# ×1
combinations ×1
language-agnostic ×1
linq ×1
search ×1
subset-sum ×1