Close
Topic list
Edit Distance
MEDIUM
30 mins
Strings
Dynamic Programming
Topics (Covered in this problem)
Problem solved
Skill meter
Strings
-
-
Dynamic Programming
-
-
Other topics
Problem solved
Skill meter
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Edit Distance

Contributed by
Arshit Babariya
Medium
0/80
Avg time to solve 30 mins
Success Rate 70 %
Share

## Problem Statement

#### Edit Distance of two strings is the minimum number of steps required to make one string equal to the other. In order to do so, you can perform the following three operations:

``````1. Delete a character
2. Replace a character with another one
3. Insert a character
``````
##### Note:
``````Strings don't contain spaces in between.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1 :
``````abc
dc
``````
##### Sample Output 1 :
``````2
``````
##### Explanation For Sample Input 1 :
``````In 2 operations we can make the string T to look like string S. First, insert the character 'a' to string T, which makes it "adc".

And secondly, replace the character 'd' of the string T with 'b' from the string S. This would make string T to "abc" which is also the string S. Hence, the minimum distance.
``````
##### Sample Input 2 :
``````whgtdwhgtdg
aswcfg
``````
##### Sample Output 2 :
``````9
``````
Auto
Console