From 8181b2609fa3624efde3888ffb94f231e5769fbf Mon Sep 17 00:00:00 2001 From: Kevin Nguyen Date: Tue, 21 Jun 2016 21:50:04 -0700 Subject: [PATCH] code for chapter 9 in javascript --- .../javascript/01_longest_common_subsequence.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 09_dynamic_programming/javascript/01_longest_common_subsequence.js diff --git a/09_dynamic_programming/javascript/01_longest_common_subsequence.js b/09_dynamic_programming/javascript/01_longest_common_subsequence.js new file mode 100644 index 0000000..f1054d0 --- /dev/null +++ b/09_dynamic_programming/javascript/01_longest_common_subsequence.js @@ -0,0 +1,7 @@ +if (word_a[i] === word_b[j]) { + // The letters match + cell[i][j] = cell[i-1][j-1] + 1; +} else { + // The letters don't match + cell[i][j] = Math.max(cell[i-1][j], cell[i][j-1]); +}