比如:1 4 2 5 9 中寻找大于6的组合
1 2 4
1 2 5
1 2 9
1 4 5
1 4 9
2 4 5
2 4 9
4 5 9
一共8个组合。
如果是自然数序列,可以先排序再找到最小的满足组合,接下来只需要复杂度为n的算法就可以得到结果。但是如果序列的值是离散的,使时间复杂度尽可能小的算法应该怎么考虑呢?
备注:
数值大于10^16
巴扎黑2017-04-17 11:23:56
Are there any problems with using the algorithm you mentioned for energy addition and comparison?
PHP中文网2017-04-17 11:23:56
Can’t we sort natural numbers? If the value is larger, you can also sort it, and the complexity is only related to the number of numbers you have