Files
java-interview-lab/dynamic-programming/output/10-partition.txt
T

15 lines
622 B
Plaintext

Partition Equal Subset Sum: [1, 5, 11, 5], target 11
====================================================
T = some subset of the first i numbers sums to s
s = 0 1 2 3 4 5 6 7 8 9 10 11
none T . . . . . . . . . . .
+1 T T . . . . . . . . . .
+5 T T . . . T T . . . . .
+11 T T . . . T T . . . . T
+5 T T . . . T T . . . T T
[1, 5, 11, 5] -> true (5 + 5 + 1 = 11 = 11)
[1, 2, 3, 5] -> false (total 11 is odd)
[1, 2, 4] -> false (total 7 is odd)