Update solution 0494. Considering new edge test case.

This commit is contained in:
zhufenggood
2021-09-02 18:01:03 +08:00
parent 61a586e96a
commit e89003a2e3

View File

@ -63,7 +63,7 @@ func findTargetSumWays(nums []int, S int) int {
for _, n := range nums {
total += n
}
if S > total || (S+total)%2 == 1 {
if S > total || (S+total)%2 == 1 || S+total < 0 {
return 0
}
target := (S + total) / 2