Skip to content

Commit

Permalink
Merge pull request #295 from dark-Qy/master
Browse files Browse the repository at this point in the history
修改494 dp解法,添加条件判断
  • Loading branch information
halfrost authored Dec 10, 2024
2 parents 93adea0 + 0ff840f commit a190dbe
Showing 1 changed file with 1 addition and 1 deletion.
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 || S+total < 0 {
if S+total < 0 || S > total || (S+total)%2 == 1 {
return 0
}
target := (S + total) / 2
Expand Down

0 comments on commit a190dbe

Please sign in to comment.