61. Edit distance

This is a fairly advanced problem, so I'll outline a solution before I present any code. You may want to stop reading after the outline and try to implement the algorithm on your own.

The approach I'm going to describe uses an edit graph. The edit graph is a network of nodes that represents possible changes that you can make to change the start string into the end string.

The following diagram shows an edit graph that represents changing the word Dungeon into the word Dragon:

The starting word's letters fill the top row of nodes, not counting the node in the upper left corner. The end word's letters fill the left column of ...

Get The Modern C# Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.