Skip to content

Commit 9e65340

Browse files
Merge pull request youngyangyang04#1072 from Xiaofei-fei/master
修改0494.目标和 python代码
2 parents 292942d + 2f1c56e commit 9e65340

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

.DS_Store

8 KB
Binary file not shown.

problems/0494.目标和.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ Python:
272272
class Solution:
273273
def findTargetSumWays(self, nums: List[int], target: int) -> int:
274274
sumValue = sum(nums)
275-
if target > sumValue or (sumValue + target) % 2 == 1: return 0
275+
#注意边界条件为 target>sumValue or target<-sumValue or (sumValue + target) % 2 == 1
276+
if abs(target) > sumValue or (sumValue + target) % 2 == 1: return 0
276277
bagSize = (sumValue + target) // 2
277278
dp = [0] * (bagSize + 1)
278279
dp[0] = 1

0 commit comments

Comments
 (0)