This commit is contained in:
Logen
2023-01-25 12:46:13 -06:00
parent 88750b1190
commit 27ba94b581

View File

@ -224,7 +224,7 @@ class Solution:
def lastStoneWeightII(self, stones: List[int]) -> int:
sumweight = sum(stones)
target = sumweight // 2
dp = [0] * 15001
dp = [0] * (target + 1)
for i in range(len(stones)):
for j in range(target, stones[i] - 1, -1):
dp[j] = max(dp[j], dp[j - stones[i]] + stones[i])