From 0ff840fe0dfce5876a35f9cd4fc6852d2c4a47e6 Mon Sep 17 00:00:00 2001 From: dark-Qy <2454271718@qq.com> Date: Thu, 5 Dec 2024 12:43:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9494=20dp=E8=A7=A3=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=9D=A1=E4=BB=B6=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- leetcode/0494.Target-Sum/494. Target Sum.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leetcode/0494.Target-Sum/494. Target Sum.go b/leetcode/0494.Target-Sum/494. Target Sum.go index 804152328..8adde19c7 100644 --- a/leetcode/0494.Target-Sum/494. Target Sum.go +++ b/leetcode/0494.Target-Sum/494. Target Sum.go @@ -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