Edit Distance

Given two words A and B, find the minimum number of steps required to convert A to B. (each operation is counted as 1 step.)

You have the following 3 operations permitted on a word:

  • Insert a character
  • Delete a character
  • Replace a character

Example :
edit distance between
"Anshuman" and "Antihuman" is 2.

  • Operation 1: Replace s with t.
  • Operation 2: Insert i.
Interview Code Editor
Hints
  • Solution Approach
  • Complete Solution
3280 successful submissions.
Asked In:
  • Google
  • LinkedIn
  • Microsoft
Click here to jump start your coding interview preparation