Merge b6724792420e1e39c03b00595bd009fd2a0b7cc4 into b70121d377cb6005eb65f12b098cd5decd905669

This commit is contained in:
Gabriel 2023-07-20 02:07:09 -07:00 committed by GitHub
commit e537a29b64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;