DEV Community

Cover image for Levenshtein Distance (Part 1: What is it?)

Levenshtein Distance (Part 1: What is it?)

James Turner on February 07, 2020

The Levenshtein Distance is a deceptively simple algorithm - by looping over two strings, it can provide the "distance" (the number of differences)...
Collapse
 
xanderyzwich profile image
Corey McCarty

I will be disappointed if your first efficiency fix isn't reduction of the matrix to current row and row above. None of the rows above these two matter at any given time. Great post, thanks! I now really want to play with this using long strings with whole words added in the middle.

Collapse
 
turnerj profile image
James Turner

I don't want to spoil anything but... yep, that is the first major memory optimization.

With your specific example though, I think you will like one or two of the other performance improvements more. 🙂

Collapse
 
codmar profile image
Codmar

I did once to find out some keyword mistakes in some documents and correct those words automatically. It was pretty cool haha