Add dynamic-programming module: ten classic DP problems, memoization vs tabulation vs space-optimised, call-count and pitfall transcripts (11 tests)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user