Skip to content

Instantly share code, notes, and snippets.

@antyakushev
Created November 2, 2016 00:40
Show Gist options
  • Save antyakushev/caf63ca73b42e8c36066da430ec14ea9 to your computer and use it in GitHub Desktop.
Save antyakushev/caf63ca73b42e8c36066da430ec14ea9 to your computer and use it in GitHub Desktop.
function d(s1, s2) {
return function _d(m, n) {
if (m == 0) {
return n
}
if (n == 0) {
return m
}
return Math.min(
_d(m, n - 1) + 1,
_d(m - 1, n) + 1,
_d(m - 1, n - 1) + (s1[m - 1] === s2[n - 1] ? 0 : 1)
)
}(s1.length, s2.length)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment