Add Elixir example for longest common subsequence

This commit is contained in:
Evgeny Garlukovich
2018-02-14 23:04:14 +03:00
committed by Aditya Bhargava
parent 51c5cfb058
commit 2ff9912e77

View File

@@ -0,0 +1,12 @@
# `cell` is a map of maps here, e.g.
# cell = %{
# 0 => %{0 => 0, ...},
# 1 => %{...},
# ...
# }
if String.at(word_a, i) == String.at(word_a, j) do
put_in(cell[i - 1][j - 1], cell[i - 1][j - 1] + 1)
else
put_in(cell[i - 1][j - 1], max(cell[i - 1][j], cell[i][j - 1]))
end