Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 778 Bytes

File metadata and controls

41 lines (28 loc) · 778 Bytes

416. Question 416

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : April 07, 2025

Last updated : April 07, 2025


Related Topics : N/A

Acceptance Rate : Unknown


Solutions

Python

class Solution:
    def canPartition(self, nums: List[int]) -> bool:
        tot = sum(nums)
        if tot % 2 :
            return False
        dp = [True] + [False] * (tot // 2)

        for num in nums :
            for i in range(len(dp) - 1, num - 1, -1) :
                dp[i] = dp[i] or dp[i - num]

        return dp[-1]