Minimum String Transformation Steps

Hard
dynamic-programming string edit-distance levenshtein
Problem Description

Find the minimum number of single-character edit operations (insert, delete, or replace) required to transform one string into another. This is known as the Levenshtein distance or edit distance.

Input Format
Two strings on separate lines.
Output Format
Single integer representing the minimum edit distance.
Constraints
• 0 ≤ string length ≤ 1000
• Strings contain only lowercase English letters
• Three operations allowed: insert, delete, replace
• Each operation has cost 1
• Empty strings are allowed
Sample Input/Output
Input:
kitten
sitting
Output:
3
Explanation

Transformations: kitten → sitten (replace k with s), sitten → sittin (replace e with i), sittin → sitting (insert g). Total: 3 operations.

Solution Hints
150
Points
3000ms
Time Limit
256MB
Memory Limit
Code Editor
Register to Submit
Register to Access Code Editor

Create a free account to solve coding problems and track your progress.

Register Now
Feedback