mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
Update solution 0494. Considering new edge test case.
This commit is contained in:
@ -6,7 +6,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
|
||||
|
Reference in New Issue
Block a user