Skip to content

Commit 2ff9912

Browse files
spadarjauhienegonSchiele
authored andcommitted
Add Elixir example for longest common subsequence
1 parent 51c5cfb commit 2ff9912

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# `cell` is a map of maps here, e.g.
2+
# cell = %{
3+
# 0 => %{0 => 0, ...},
4+
# 1 => %{...},
5+
# ...
6+
# }
7+
8+
if String.at(word_a, i) == String.at(word_a, j) do
9+
put_in(cell[i - 1][j - 1], cell[i - 1][j - 1] + 1)
10+
else
11+
put_in(cell[i - 1][j - 1], max(cell[i - 1][j], cell[i][j - 1]))
12+
end

0 commit comments

Comments
 (0)