Update levenshteinDistance.md

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-12-29 12:56:07 +02:00
committed by GitHub
parent 31faa2ee2b
commit 8e0ff8babc

View File

@ -15,9 +15,7 @@ Calculates the difference between two strings.
const levenshteinDistance = (s, t) => {
if (!s.length) return t.length;
if (!t.length) return s.length;
const arr = [];
for (let i = 0; i <= t.length; i++) {
arr[i] = [i];
for (let j = 1; j <= s.length; j++) {
@ -31,7 +29,6 @@ const levenshteinDistance = (s, t) => {
);
}
}
return arr[t.length][s.length];
};
```