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.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Edit Distance on Interview Code Editor
Sign Up
to access hints and editorial solutions for Edit Distance


Click here to start solving coding interview questions