Skip to content

Commit 02795ef

Browse files
authored
Merge pull request neetcode-gh#1355 from sezanhaque/205
Create: 205-Isomorphic-Strings.py
2 parents 9dfd521 + db52261 commit 02795ef

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

python/205-Isomorphic-Strings.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution:
2+
def isIsomorphic(self, s: str, t: str) -> bool:
3+
mapST, mapTS = {}, {}
4+
5+
for c1, c2 in zip(s, t):
6+
if (c1 in mapST and mapST[c1] != c2) or (c2 in mapTS and mapTS[c2] != c1):
7+
return False
8+
mapST[c1] = c2
9+
mapTS[c2] = c1
10+
11+
return True

0 commit comments

Comments
 (0)