From d71ad02ab48de3432f2ec6f15e0742f0c11c2e58 Mon Sep 17 00:00:00 2001 From: Sujin Sreekumaran Date: Wed, 31 Jan 2024 17:01:11 +0000 Subject: [PATCH] isomorphic string --- problems/Array/leetcode_205.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/problems/Array/leetcode_205.py b/problems/Array/leetcode_205.py index e69de29..09f7237 100644 --- a/problems/Array/leetcode_205.py +++ b/problems/Array/leetcode_205.py @@ -0,0 +1,11 @@ +class Solution: + def isIsomorphic(self, s: str, t: str) -> bool: + mapST, mapTS = {}, {} + + for c1, c2 in zip(s, t): + if((c1 in mapST and mapST[c1] != c2) or (c2 in mapTS and mapTS[c2] != c1)): + return False + mapST[c1] = c2 + mapTS[c2] = c1 + return True + \ No newline at end of file