Update Leetcode 题解 - 动态规划.md
fixed 494\. Target Sum (Medium)
This commit is contained in:
parent
2c31eddf34
commit
b672479242
@ -807,7 +807,7 @@ sum(P) + sum(N) + sum(P) - sum(N) = target + sum(P) + sum(N)
|
|||||||
```java
|
```java
|
||||||
public int findTargetSumWays(int[] nums, int S) {
|
public int findTargetSumWays(int[] nums, int S) {
|
||||||
int sum = computeArraySum(nums);
|
int sum = computeArraySum(nums);
|
||||||
if (sum < S || (sum + S) % 2 == 1) {
|
if (sum < Math.abs(S) || (sum + S) % 2 == 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int W = (sum + S) / 2;
|
int W = (sum + S) / 2;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user