This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
This is a classic DP problem. Let f ( i , j ) determine edit distance between character array A [ 0 . . . i − 1 ] and B [ 0 . . . j − 1 ] . Note that f ( 0 , x ) = f ( x , 0 ) = x . More ever, if A [ i − 1 ] = = B [ j − 1 ] , f ( i , j ) = f ( i − 1 , j − 1 ) or else, f ( i , j ) = min ( f ( i − 1 , j − 1 ) , f ( i − 1 , j ) , f ( i , j − 1 ) ) + 1 .
This can be implemented by used a 2D array and then building up the f ( i , j ) table.