未验证 提交 68da17c8 编写于 作者: C CyC2018 提交者: GitHub

Merge pull request #550 from aaaaaabiao/patch-1

leetcode解题修改-划分数组为和相等的两部分
......@@ -3050,7 +3050,6 @@ public boolean canPartition(int[] nums) {
int W = sum / 2;
boolean[] dp = new boolean[W + 1];
dp[0] = true;
Arrays.sort(nums);
for (int num : nums) { // 0-1 背包一个物品只能用一次
for (int i = W; i >= num; i--) { // 从后往前,先计算 dp[i] 再计算 dp[i-num]
dp[i] = dp[i] || dp[i - num];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册