Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def areAlmostEqual(self, s1: str, s2: str) -> bool:
- c=0
- x={}
- a={}
- for i in range(len(s1)):
- if s1[i] not in x:
- x[s1[i]]=1
- else:
- x[s1[i]]+=1
- if s2[i] not in a:
- a[s2[i]]=1
- else:
- a[s2[i]]+=1
- if s1[i]!=s2[i]:
- c+=1
- if (c==2 or c==0) and sorted(x.items())==sorted(a.items()):
- return True
- else:
- return False
Advertisement
Add Comment
Please, Sign In to add comment