当前位置:网站首页>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;
}
};边栏推荐
猜你喜欢

2022危险化学品经营单位主要负责人练习题及模拟考试

分布式BASE理论

Go 语言入门很简单:Go 实现凯撒密码

2022 hoisting machinery command examination simulation 100 questions simulation examination platform operation

Dgraph: large scale dynamic graph dataset

博士申请 | 西湖大学学习与推理系统实验室招收博后/博士/研究实习等

免费、好用、强大的轻量级笔记软件评测:Drafts、Apple 备忘录、Flomo、Keep、FlowUs、Agenda、SideNote、Workflowy

OPPO Find N2产品形态首曝:补齐各项短板

How to choose a technology stack for web applications in 2022

Oracle 被 Ventana Research 评为数字创新奖总冠军
随机推荐
2022 Shandong Province safety officer C certificate examination question bank and online simulation examination
C basic supplement
Dgraph: large scale dynamic graph dataset
C语言程序设计
The Secretary of Homeland Security warned immigrants "not to embark on a dangerous journey"
Optional values and functions of the itemized contenttype parameter in the request header
结合案例:Flink框架中的最底层API(ProcessFunction)用法
担心“断气” 德国正修改《能源安全法》
Fisher信息量检测对抗样本代码详解
C foundation in-depth learning II
源码编译安装MySQL
Worried about "cutting off gas", Germany is revising the energy security law
.NET 使用 redis
Database lock table? Don't panic, this article teaches you how to solve it
JVM series - stack and heap, method area day1-2
免费、好用、强大的轻量级笔记软件评测:Drafts、Apple 备忘录、Flomo、Keep、FlowUs、Agenda、SideNote、Workflowy
Redis - how to install redis and configuration (how to quickly install redis on ubuntu18.04 and centos7.6 Linux systems)
安装trinity、解决报错
C language programming topic reference
分布式BASE理论