The Levenshtein distance between two strings is a minimum number
of edits needed to transform one string into the other, with the
allowable edit operations being insertion, deletion,
or substitution of a single character.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
s |
String
|
Source string. |
t |
String
|
Target string. |
Returns:
- Type:
-
Number
Minimum number of edits needed
to transform source string into the target string.
Example
var dist = require('path-to-algorithms/src/others/' +
'levenshtein-distance').levenshteinDistance;
console.log(dist('kitten', 'sitting')); // 3