Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bbc0a41

Browse files
Create 1790.py
1 parent 576ef50 commit bbc0a41

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎1601-1800/1790.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution(object):
2+
def areAlmostEqual(self, s1, s2):
3+
"""
4+
:type s1: str
5+
:type s2: str
6+
:rtype: bool
7+
"""
8+
i=-1
9+
j=-1
10+
cnt=0
11+
for k in range(0, len(s1)):
12+
if s1[k]!=s2[k]:
13+
cnt+=1
14+
if i==-1: i=k
15+
elif j==-1: j=k
16+
17+
if cnt==0: return True
18+
elif cnt==2 and s1[i]==s2[j] and s1[j]==s2[i]: return True
19+
20+
return False

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /