Created
November 2, 2016 00:40
-
-
Save antyakushev/caf63ca73b42e8c36066da430ec14ea9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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