Mark As Completed Discussion

... the original problem statement may be converted into the following subset sum problem: find the number of ways to gather a subset of nums such that its sum is equal to (target + sum(nums)) / 2.

We can also add another trivial check to our algorithm: if target + sum(nums) is not divisible by 2, we can return 0 because there is no solution (this follows from the last line in our derivation above).

Therefore, the crux of this reformulated problem statement is (in pseudo-code):

TEXT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment