0%
1 2 3 4 5 6 7 8 9 10 11
| class Solution: def lastStoneWeightII(self, stones: List[int]) -> int: target = sum(stones)//2 d = [0]*(target+1) for i in range(len(stones)): for j in range(target,stones[i]-1,-1): d[j] = max(d[j],d[j-stones[i]]+stones[i]) print(sum(stones),target,d) return sum(stones)-d[target]-d[target]
|