Edit Distance
DP on Strings DSA practice problem on Onlearn.
Difficulty: hard.
Topics: Edit Distance: Minimum Operations to Convert One String to Another, Strings, String Manipulation, Recursion, Dynamic Programming, Memoization, Tabulation, Space Optimization, Base Cases, Overlapping Subproblems, Optimal Substructure, Time Complexity, Space Complexity, dynamic programming, string manipulation, memoization, tabulation, space optimization, recursion.
Edit Distance Problem Statement Given two strings, S1 and S2, you need to find the minimum number of operations required to convert S1 into S2. The allowed operations are: 1. Deletion of a character. 2. Replacement of a character with another one. 3. Insertion of a character. Input Specification Two strings, S1 and S2. Output Specification An integer representing the minimum number of operations. Constraints 1 <= len(S1), len(S2) <= 1000 S1 and S2 consist of lowercase English letters. Sample Test Cases Sample Input 1 S1 = "horse" S2 = "ros" Sample Output 1 3 Explanation 1 1. horse rorse (replace 'h' with 'r') 2. rorse rose (delete 'r') 3. rose ros (delete 'e')