@zitro/edit-distance
v1.0.1
Published
A tiny optimized package which finds the Levenshtein distance (edit distance) between two words. Having two strings of length N and M, the algorithm has O(N*M) complexity and uses O(N) additional space.
Downloads
3
Maintainers
Readme
Edit Distance
A tiny optimized package which finds the Levenshtein distance (edit distance) between two words. Having two strings of length N and M, the algorithm has O(N*M) complexity and uses O(N) additional space. The comparison is case sensitive.
Installation
npm install --save @zitro/edit-distance
Usage
import editDistance from "@zitro/edit-distance";
editDistance("jelly", "fully"); // === 2 (replace 2 letters "je" to "fu")
editDistance("cars", "girls"); // === 3 (replace 2 letters "ca" to "gi", add 1 letter "l")
editDistance(["c", "a", "r", "s"], ["g", "i", "r", "l", "s"]); // yields the same result