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
  • Solution Approach
  • Complete Solution
4514 successful submissions.
Asked In:
  • Google
  • LinkedIn
  • Microsoft
Click here to jump start your coding interview preparation