Understanding isomorphic strings algorithm

后端 未结 4 1246
梦谈多话
梦谈多话 2021-01-27 08:15

I am understanding the following code to find if the strings are isomorphic or not. The code uses two hashes s_dict and t_dict respectively. I am assum

4条回答
  •  [愿得一人]
    2021-01-27 08:42

    Thinking about it without maps or dictionaries can help you understand:

    def isIso(x,y):
      if len(x) != len(y):
        return False
      for i in range(len(x)):
        count = 0
        if x.count(x[i]) != y.count(y[i]):
          return False
      return True
    

提交回复
热议问题