Skip to content

Commit a190dbe

Browse files
authored
Merge pull request #295 from dark-Qy/master
修改494 dp解法,添加条件判断
2 parents 93adea0 + 0ff840f commit a190dbe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

leetcode/0494.Target-Sum/494. Target Sum.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ func findTargetSumWays(nums []int, S int) int {
66
for _, n := range nums {
77
total += n
88
}
9-
if S > total || (S+total)%2 == 1 || S+total < 0 {
9+
if S+total < 0 || S > total || (S+total)%2 == 1 {
1010
return 0
1111
}
1212
target := (S + total) / 2

0 commit comments

Comments
 (0)