Back to course home
0% completed
Minimum Deletions & Insertions to Transform a String into another
Problem Statement
Given strings s1 and s2, we need to transform s1 into s2 by deleting and inserting characters. Write a function to calculate the count of the minimum number of deletion and insertion operations.
Example 1:
Input: s1 = "abc"
s2 = "fbc"
Output: 1 deletion and 1 insertion.
Explanation: We need to delete {'a'} and insert {'f'} to s1 to transform it into s2.
Example 2:
Input: s1 = "abdca"
s2 = "cbda"
Output: 2 deletions and 1 insertion.
Explanation: We need to delete {'a', 'c'} and insert {'c'} to s1 to transform it into s2.
.....
.....
.....
Like the course? Get enrolled and start learning!