diff options
| -rw-r--r-- | challenge-096/abigail/lua/ch-2.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/challenge-096/abigail/lua/ch-2.lua b/challenge-096/abigail/lua/ch-2.lua index bb1b042b19..162f06eef0 100644 --- a/challenge-096/abigail/lua/ch-2.lua +++ b/challenge-096/abigail/lua/ch-2.lua @@ -33,6 +33,16 @@ function LevenshteinDistance (first, second) ) end end + + -- + -- We only need the previous row, so we can return the + -- memory of rows before that. This reduces the memory + -- usage from O (n * m) to O (min (n, m)) + -- + if i > 0 + then + distances [i - 1] = nil + end end return distances [n] [m] end |
