<filename>205. Isomorphic Strings/better.py
class Solution():
    def isIsomorphic(self, s, t):
        d1, d2 = [0 for _ in range(256)], [0 for _ in range(256)]
        for i in range(len(s)):
            if d1[ord(s[i])] != d2[ord(t[i])]:
                return False
            d1[ord(s[i])] = i + 1
            d2[ord(t[i])] = i + 1
        return True


s = "foo"
t = "app"
print(Solution().isIsomorphic(s, t))

<filename>205. Isomorphic Strings/better.py
class Solution():
    def isIsomorphic(self, s, t):
        d1, d2 = [0 for _ in range(256)], [0 for _ in range(256)]
        for i in range(len(s)):
            if d1[ord(s[i])] != d2[ord(t[i])]:
                return False
            d1[ord(s[i])] = i + 1
            d2[ord(t[i])] = i + 1
        return True


s = "foo"
t = "app"
print(Solution().isIsomorphic(s, t))
