mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 07:35:35 +08:00
494题python代码修正
This commit is contained in:
@ -272,7 +272,8 @@ Python:
|
||||
class Solution:
|
||||
def findTargetSumWays(self, nums: List[int], target: int) -> int:
|
||||
sumValue = sum(nums)
|
||||
if target > sumValue or (sumValue + target) % 2 == 1: return 0
|
||||
#注意边界条件为 target>sumValue or target<-sumValue or (sumValue + target) % 2 == 1
|
||||
if abs(target) > sumValue or (sumValue + target) % 2 == 1: return 0
|
||||
bagSize = (sumValue + target) // 2
|
||||
dp = [0] * (bagSize + 1)
|
||||
dp[0] = 1
|
||||
|
Reference in New Issue
Block a user