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:
2026-11-09 08:41:01 +00:00
parent 911aef5515
commit cb1b28682f
33 changed files with 1551 additions and 0 deletions
@@ -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)