One Away
There are three types of edits that can be performed on strings:
- Insert a character
- Remove a character
- Replace a character
Given two strings, write a function to check if they are one edit (or zero edits) away.
Examples:
("pale", "ple") → True (remove 'a')
("pales", "pale") → True (remove 's')
("pale", "bale") → True (replace 'p' with 'b')
("pale", "bake") → False (two replacements)
Hints
solution.py
Python ready
Test Output
▶
Click "Run Tests" to execute your code