当前位置:网站首页>205. 同构字符串
205. 同构字符串
2022-07-04 12:48:00 【anieoo】
原题链接:205. 同构字符串
solution:
保证一个字母对应一个映射
class Solution {
public:
bool isIsomorphic(string s, string t) {
unordered_map<char,char> st,ts;
int n = s.size();
//保证一个字母只有一个映射即可
for(int i = 0;i < n;i++) {
if(st.count(s[i])) {
if(st[s[i]] != t[i]) return false;
} else {
st[s[i]] = t[i];
}
if(ts.count(t[i])) {
if(ts[t[i]] != s[i]) return false;
} else {
ts[t[i]] = s[i];
}
}
return true;
}
};
边栏推荐
- 面试拆解:系统上线后Cpu使用率飙升如何排查?
- CTF competition problem solution STM32 reverse introduction
- [AI system frontier dynamics, issue 40] Hinton: my deep learning career and research mind method; Google refutes rumors and gives up tensorflow; The apotheosis framework is officially open source
- WPF double slider control and forced capture of mouse event focus
- C语言中学生成绩管理系统
- #yyds干货盘点# 解决名企真题:连续最大和
- 近日小结(非技术文)
- C language dormitory management query software
- Xilinx/system-controller-c/boardui/ unable to connect to the development board, the solution of jamming after arbitrary operation
- C语言课程设计题
猜你喜欢
2022 Shandong Province safety officer C certificate examination question bank and online simulation examination
Byte interview algorithm question
CVPR 2022 | 大幅减少零样本学习所需的人工标注,提出富含视觉信息的类别语义嵌入(源代码下载)...
Oracle 被 Ventana Research 评为数字创新奖总冠军
8 expansion sub packages! Recbole launches 2.0!
逆向调试入门-PE结构-资源表07/07
CA: efficient coordinate attention mechanism for mobile terminals | CVPR 2021
硬件基础知识-二极管基础
ViewBinding和DataBinding的理解和区别
One of the solutions for unity not recognizing riders
随机推荐
Summary of recent days (non-technical article)
Animation and transition effects
苹果5G芯片研发失败:继续依赖高通,还要担心被起诉?
2022kdd pre lecture | 11 first-class scholars take you to unlock excellent papers in advance
2022g3 boiler water treatment examination question simulation examination question bank and simulation examination
担心“断气” 德国正修改《能源安全法》
数据库公共字段自动填充
CVPR 2022 | transfusion: Lidar camera fusion for 3D target detection with transformer
Personalized online cloud database hybrid optimization system | SIGMOD 2022 selected papers interpretation
Five "potential errors" in embedded programming
JVM系列——栈与堆、方法区day1-2
The old-fashioned synchronized lock optimization will make it clear to you at once!
Scrapy 框架学习
C语言职工管理系统
一次 Keepalived 高可用的事故,让我重学了一遍它
Oracle was named the champion of Digital Innovation Award by Ventana research
Node の MongoDB 安装
Getting started with microservices
2022 hoisting machinery command examination simulation 100 questions simulation examination platform operation
【R语言数据科学】:交叉验证再回首