<jupyter_start><jupyter_text>给定一个仅包含正整数的非空数组，请确定该数组是否可以划分为两个子集，以使两个子集中的元素之和相等。    注意：每个数组元素将不超过100。数组大小将不超过200。    例1：        Input: [1, 5, 11, 5]        Output: true        Explanation: The array can be partitioned as [1, 5, 5] and [11].    例2：        Input: [1, 2, 3, 5]        Output: false        Explanation: The array cannot be partitioned into equal sum subsets.<jupyter_code>class Solution:
    def canPartition(self, nums) -> bool:
        sum_val = sum(nums)
        if sum_val % 2 != 0: return False
        
        dp = [0] * (sum_val + 1)
        dp[0] = True
        for num in nums:
            for i in range(sum_val, -1, -1):
                if i >= num:
                    print(i, num, i-num)
                    dp[i] = dp[i] or dp[i - num]
                    print(dp)
        return dp[-1]
nums_ = [1, 5, 11, 5]
solution = Solution()
solution.canPartition(nums_)<jupyter_output>22 1 21
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
21 1 20
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
20 1 19
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
19 1 18
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
18 1 17
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
17 1 16
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
16 1 15
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
15 1 14
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
14 1 13
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
13 1 12
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
12 1 11
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
11 1 10
[True, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
10 1 9
[True, 0, 0, 0, 0, 0,[...]
{'fraction_non_alphanumeric': 0.21226415094339623, 'fraction_numerical': 0.1928721174004193, 'mean_word_length': 2.001572327044025, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '26929', 'license': 'Apache-2.0', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1005, 'n_words': 412, 'path': 'Dynamic Programming/0731/416. Partition Equal Subset Sum.ipynb', 'repo_name': 'YuHe0108/Leetcode', 'size': '1908'}