@@ -0,0 +1,1088 @@
+import unittest%0Afrom typing import List%0A%0Aimport utils%0A%0A%0A# O(sum(nums)) time. O(sum(nums)) space. DP, array.%0Aclass Solution:%0A    def canPartition(self, nums: List%5Bint%5D) -%3E bool:%0A        s = sum(nums)%0A        if s & 1:%0A            return False%0A%0A        target = s %3E%3E 1%0A        sums = %5BFalse%5D * target%0A%0A        for num in nums:%0A            if num == target:%0A                return True%0A%0A            for s in range(target - 1, -1, -1):%0A                if not sums%5Bs%5D:%0A                    continue%0A%0A                s += num%0A%0A                if s %3C target:%0A                    sums%5Bs%5D = True%0A                elif s == target:%0A                    return True%0A%0A            if num %3C target:%0A                sums%5Bnum%5D = True%0A%0A        return False%0A%0A%0Aclass Test(unittest.TestCase):%0A    def test(self):%0A        cases = utils.load_test_json(__file__).test_cases%0A%0A        for case in cases:%0A            args = str(case.args)%0A            actual = Solution().canPartition(**case.args.__dict__)%0A            self.assertEqual(case.expected, actual, msg=args)%0A%0A%0Aif __name__ == '__main__':%0A    unittest.main()%0A

416. Partition Equal Subset Sum