Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update solution 0494. Considering new edge test case.
  • Loading branch information
zhufenggood committed Sep 2, 2021
commit 61a586e96a839328ea25feabb0fcf2aa838d77f1
2 changes: 1 addition & 1 deletion leetcode/0494.Target-Sum/494. Target Sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down