We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 56502a0 commit dfb64e4Copy full SHA for dfb64e4
161_one_edit_distance/one_edit_distance.py
@@ -0,0 +1,22 @@
1
+class Solution(object):
2
+ def isOneEditDistance(self, s, t):
3
+ """
4
+ :type s: str
5
+ :type t: str
6
+ :rtype: bool
7
8
+ if abs(len(s)-len(t))>1:
9
+ return False
10
+ if len(s)==len(t):
11
+ diff = 0
12
+ for i in range(len(s)):
13
+ if s[i]!=t[i]:
14
+ diff += 1
15
+ if diff>1: return False
16
+ return diff==1
17
+ if len(s)<len(t):
18
+ s, t = t, s
19
+ for i in range(len(t)):
20
21
+ return s[i+1:]==t[i:]
22
+ return True
161_one_edit_distance/problem.txt
@@ -0,0 +1 @@
+Given two strings S and T, determine if they are both one edit distance apart.
0 commit comments