End of Year Sale: Use Coupon Code END2025 to Get Extra 25% Off.
nums.false as we cannot partition the array into two subsets with equal sum.dp with a size of half_sum + 1, where half_sum is half of the total sum. Set dp[0] to true as a subset with sum 0 is always possible (empty subset).half_sum to the number itself.dp[j] to true if dp[j] is true or if dp[j - num] is true, where num is the current number in the array.dp[half_sum] is true, return true, indicating that we can partition the array into two subsets with equal sum.dp[half_sum] is false, return false.