Skip to content

Commit 3c69972

Browse files
author
Joseph Luce
authored
Update 416_partition_equal_subset_sum.md
1 parent c05a654 commit 3c69972

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

leetcode/medium/416_partition_equal_subset_sum.md

+5
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,13 @@ Final DP:
7777
```
7878

7979
The intuition is gathered by using the two questions we asked earlier, whether to keep this number or not.
80+
8081
To not keep this number is simply looking at the current sum and the previous number.
82+
That is because if we could not use this number which can be defined that previous number + 0, then the previous number needs to be True to add up to this current sum.
83+
8184
To keep this number, we have to look at the current sum - current number of the previous number.
85+
That would mean some previous sum from nums[:i] must have been True for us to perform sum(nums[:i]) + nums[i] == current sum.
86+
8287
dp\[curr_sum][curr_num] = dp\[curr_sum][prev_num] or dp\[curr_sum-curr_num][prev_num]
8388

8489
```

0 commit comments

Comments
 (0)