May 24, 2019
Career strategy, tech news, and interview questions in your inbox. A newsletter for the ambitious developer.
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
- C. A. R. Hoare
An edit distance is a way to quantify how different two strings are. This is calculated using the minimum number of transformations to turn one string to another.
The transformations include
substitution. So when comparing two identical strings, the edit distance would be
0-- there is only an edit distance for differences.
As an example, here's the edit distance for
getEditDistance('mitten', 'sitting'); // 3
Here's the rationale in terms of transformation steps:
1. mitten -> sitten (substitution of "s" for "m") 2. sitten -> sittin (substitution of "i" for "e") 3. sittin -> sitting (insertion of "g" at the end).
Thanks for reading! Enjoy the rest of your day, and feel free to share and forward this email to a friend :-)
See you tomorrow,