Dsa
Strings
Hard
String Ladder Transformations
You are given two strings and can perform the following operations to transform the first string into the second: replace a character, insert a character, or delete a character. Calculate the minimum number of transformations needed to achieve this.
Input Format:
Two lines, the first being the original string and the second being the desired string.
Output Format:
An integer representing the minimum number of transformations required.
Example:
Input:
kitten
sitting
Output:
3
Explanation: The transformations are: replace 'k' with 's', replace 'e' with 'i', and insert 'g'.
Key concepts
stringstransformationsedit-distance
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now