gpt4 book ai didi

java - 搜索子集(有趣的复杂任务)

转载 作者:行者123 更新时间:2023-11-30 11:57:17 25 4
gpt4 key购买 nike

我刚刚在做Greplin programming challenge然后进入最后一关,任务听起来是这样的:

For the final task, you must find all subsets of an array
where the largest number is the sum of the remaining numbers.
For example, for an input of:

(1, 2, 3, 4, 6)

the subsets would be

1 + 2 = 3
1 + 3 = 4
2 + 4 = 6
1 + 2 + 3 = 6

Here is the list of numbers (3, 4, 9, 14, 15, 19, 28, 37, 47, 50, 54, 56, 59, 61, 70, 73, 78, 81, 92, 95, 97, 99)
you should run your code on.
The password is the number of subsets. In the above case the
answer would be 4.

你能给我一个建议我应该在这里做什么吗?我认为蛮力不适合这里,是吗?

不要写代码!

谢谢。

最佳答案

使用dynamic programming ,较小数字的解决方案可以扩展到较大数字的解决方案。

关于java - 搜索子集(有趣的复杂任务),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3902166/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com