Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a190dbe

Browse files
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

Lines changed: 1 addition & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /