Edit Distance
Given two strings word1 and word2, return the minimum number of edits required to convert word1 into word2.
In one edit you may insert a character, delete a character, or replace a character, and each of those operations counts as exactly one edit. This is the classic Levenshtein distance.
Examples
Input: ["horse","ros"]
Output: 3
Input: ["",""]
Output: 0
Hints
Consider the base cases where one of the strings is empty; the number of edits is simply the length of the other string.
Explore the recurrence relation where characters at the current positions match, allowing you to skip an edit operation.
Optimize space complexity by reducing the DP table to two rows (or a single row) while maintaining correctness.
Related Problems
Edit Distance
Given two strings `word1` and `word2`, return the minimum number of edits required to convert `word1` into `word2`.