Isomorphic Strings

Isomorphic Strings

To keep track of mapping, of course we’ll need dictionary.

  • Think about the conditions, carefully and thoroughly.
  • Smart usage of zip().
class Solution:
    def isIsomorphic(self, s: str, t: str) -> bool:
        return len(set(s)) == len(set(t)) == len(set(zip(s, t)))
  • For other languages, we don’t have a way to keep track of all the values, or it could be expensive to do so.
  • Thus, in order to maintain a bidirectional link, we may use two dictionaries to hold that information.