Skip to content

Commit

Permalink
修改494 dp解法,添加条件判断
Browse files Browse the repository at this point in the history
  • Loading branch information
dark-Qy committed Dec 5, 2024
1 parent 93adea0 commit 0ff840f
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 0ff840f

Please sign in to comment.