https://leetcode.cn/problems/partition-equal-subset-sum/
class Solution:
def canPartition(self, nums: List[int]) -> bool:
sum = 0
dp = [0]*10001
for num in nums:
sum += num
if sum % 2 == 1:
return False
target = sum //2
for num in nums:
for i in range(target, num - 1, -1):
dp[i] = max(dp[i], dp[i - num] + num)
if dp[target] == target:
return True
return False