技术栈

205. Isomorphic Strings

ujn201612222023-12-17 8:06

LeetCode - The World's Leading Online Programming Learning Platform

python 复制代码
from collections import defaultdict
class Solution:
    def isIsomorphic(self, s: str, t: str) -> bool:
        mydict1={}
        mydict0={}
        for i in range(len(s)):
            c1=(s[i] not in mydict1)
            c0=(t[i] not in mydict0)
            if c1 and c0:
                mydict1[s[i]]=t[i]
                mydict0[t[i]]=s[i]
            elif (not c0) and (not c1):
                if mydict1[s[i]]!=t[i] or mydict0[t[i]]!=s[i]:
                    return False
            else: return False
        return True

双向map

上一篇:软考高项案例分析常见理论题汇总
下一篇:外包干了一个月,技术明显进步。。。。。
相关推荐
文丑颜不良啊
9 小时前
LeetCode2261~2280题目解析
java·leetcode
文丑颜不良啊
15 小时前
LeetCode2241~2260题目解析
java·leetcode
文丑颜不良啊
15 小时前
LeetCode2321~2340题目解析
java·leetcode
文丑颜不良啊
1 天前
LeetCode2221~2240题目解析
java·leetcode
Navigator_Z
1 天前
LeetCode //C - 1317. Convert Integer to the Sum of Two No-Zero Integers
c语言·算法·leetcode
文丑颜不良啊
1 天前
LeetCode2161~2180题目解析
java·leetcode
文丑颜不良啊
2 天前
LeetCode2141~2160题目解析
java·leetcode
Dream it possible!
2 天前
LeetCode 面试经典 150_多维动态规划_交错字符串(97_C++_中等)
算法·leetcode·面试·动态规划
心抵鹊
2 天前
算法之双指针系列(一)
算法·leetcode
Pniubi
2 天前
力扣560.和为k的子数组
算法·leetcode·职场和发展
热门推荐
01国内可直接用、免费额度/永久免费的大模型API清单(含 SiliconFlow、火山、阿里、智谱、百度、Kimi、DeepSeek、DMXAPI 等)02如何新建文件夹? 电脑新建文件夹的4种方法03历年考研数学一、数学二、数学三真题试卷及答案PDF04几个好用的ip纯净度检测网站05GitHub 镜像站点06微信历史版本含下载地址( Windows PC | 安卓 | MAC )及设置微信不更新07苹果iPA游戏软件资源下载网站08蜘蛛磁力 搜索引擎大全,如何使用蜘蛛磁力查找磁力链接09昇腾910B系列芯片完全指南:四款型号对比、服务器选型与大模型部署实战10Dify:一站式AI应用开发平台全解析与Windows部署指南