Calculates the Levenshtein distance between two strings.
[!NOTE] The complexity of this function is O(m * n), where m and n are the lengths of the two strings. It's recommended to limit the length and validate input if arbitrarily accepting input.
The first string.
The second string.
The Levenshtein distance between the two strings.
import { levenshteinDistance } from "@std/text/levenshtein-distance";import { assertEquals } from "@std/assert";assertEquals(levenshteinDistance("aa", "bb"), 2); Copy
import { levenshteinDistance } from "@std/text/levenshtein-distance";import { assertEquals } from "@std/assert";assertEquals(levenshteinDistance("aa", "bb"), 2);
Calculates the Levenshtein distance between two strings.