56 if (len_s == 0)
return len_t;
57 if (len_t == 0)
return len_s;
58 if (!strncmp(s, t, std::min(len_s, len_t)))
return 0;
61 size_t len = len_t + 1;
62 std::vector<size_t> v0(len);
63 std::vector<size_t> v1(len);
68 for (
size_t i = 0; i < len; i++)
71 for (
size_t i = 0; i < len_s; i++) {
79 for (
size_t j = 0; j < len_t; j++) {
80 size_t cost = (s[i] == t[j]) ? 0 : 1;
81 v1[j+1] = std::min(v1[j] + 1,
82 std::min(v0[j + 1] + 1,
87 for (
size_t j = 0; j < len; j++)
size_t LevenshteinDistance(const char *s, size_t len_s, const char *t, size_t len_t)