Last active
May 6, 2019 07:38
-
-
Save SantonyChoi/c3d957b74d65a41d0a69052a814e9431 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def equalsWhenOneCharRemoved(x, y): | |
| if abs(len(x) - len(y)) != 1: | |
| return False | |
| return compareEachChars(x, y, False) | |
| def compareEachChars(a, b, has_removed): | |
| if not a or not b: | |
| return True | |
| if a[0] != b[0]: | |
| if has_removed: | |
| return False | |
| elif len(a) > len(b): | |
| return compareEachChars(a[1:], b, True) | |
| else: | |
| return compareEachChars(a, b[1:], True) | |
| else: | |
| return compareEachChars(a[1:],b[1:], has_removed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment