zoukankan      html  css  js  c++  java
  • 【leetcode❤python】 205. Isomorphic Strings

    class Solution(object):
        def isIsomorphic(self, s, t):
            """
            :type s: str
            :type t: str
            :rtype: bool
            """
            sdic={}
            slist=[]
            tdic={}
            tlist=[]
            
            if len(s)!=len(t):return False
            
            i=0;tag=0
            while i<len(s):
                if(sdic.has_key(s[i])):
                    slist.append(sdic.get(s[i]))
                else:
                    slist.append(tag)
                    sdic.setdefault(s[i],tag)
                    tag+=1
                i+=1
            
            i=0;tag=0
            while i<len(t):
                if tdic.has_key(t[i]):
                    tlist.append(tdic.get(t[i]))
                else:
                    tlist.append(tag)
                    tdic.setdefault(t[i],tag)
                    tag+=1
                i+=1
            
            return tlist==slist

  • 相关阅读:
    移动端 app
    python 3.8 新特性
    vue 路由歪招
    VUE 关于组件依赖的问题
    vue 全局注册组件
    CSS小技巧
    vue踩坑记 页面跳转不新
    vuecli eslint 语法错误解决办法
    vue v-slot用法测试
    终止 IdFtp下载
  • 原文地址:https://www.cnblogs.com/kwangeline/p/5997979.html
Copyright © 2011-2022 走看看