Problem · Hard · 40 min
Fewest edits
- Hard
- Dynamic programming
- Strings
You can change a word with three kinds of edits. Each edit counts as one step:
- Insert one letter at any place.
- Delete one letter from any place.
- Replace one letter with another letter.
Write min_edits(a, b). It returns the smallest number of edits that turn the word a into the word b.
min_edits("cat", "cut")is 1: replaceawithu.min_edits("kitten", "sitting")is 3.- Either word can be empty.
- Each word has at most 60 letters.
Examples
| Call | Result |
|---|---|
min_edits('cat', 'cut') |
1 |
min_edits('kitten', 'sitting') |
3 |
min_edits('', 'abc') |
3 |
Tasks
2 to do
Task 1, not checked yet. Make
min_editspass the example tests.Task 2, not checked yet. Make
min_editspass the hidden tests.
Task 1 of 2
Make min_edits pass the example tests.