Last active
May 6, 2019 07:38
-
-
Save SantonyChoi/c3d957b74d65a41d0a69052a814e9431 to your computer and use it in GitHub Desktop.
Revisions
-
SantonyChoi revised this gist
May 6, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,8 +10,10 @@ def equalsWhenOneCharRemoved(x, y): if has_removed: return False elif len(x) > len(y): has_removed = True ix += 1 else: has_removed = True iy += 1 ix += 1 -
SantonyChoi revised this gist
May 6, 2019 . 1 changed file with 15 additions and 14 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,18 +2,19 @@ def equalsWhenOneCharRemoved(x, y): if abs(len(x) - len(y)) != 1: return False has_removed = False ix, iy = 0, 0 while ix < len(x) and iy < len(y): if x[ix] != y[iy]: if has_removed: return False elif len(x) > len(y): ix += 1 else: iy += 1 ix += 1 iy += 1 return True -
SantonyChoi created this gist
May 6, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ 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)