diff --git a/09_dynamic_programming/ruby/01_longest_common_subsequence.rb b/09_dynamic_programming/ruby/01_longest_common_subsequence.rb new file mode 100644 index 0000000..624023e --- /dev/null +++ b/09_dynamic_programming/ruby/01_longest_common_subsequence.rb @@ -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] = [cell[i-1][j], cell[i][j-1]].max +end