当前位置:网站首页>205. isomorphic string
205. isomorphic string
2022-06-28 01:49:00 【Mr Gao】
205. Isomorphic Strings
Given two strings s and t , Judge whether they are isomorphic .
If s The characters in can be replaced according to some mapping relationship t , So these two strings are isomorphic .
Every character that appears should be mapped to another character , Without changing the order of characters . Different characters cannot be mapped to the same character , The same character can only be mapped to the same character , Characters can be mapped to themselves .
Example 1:
Input :s = “egg”, t = “add”
Output :true
Example 2:
Input :s = “foo”, t = “bar”
Output :false
Example 3:
Input :s = “paper”, t = “title”
Output :true
bool isIsomorphic(char * s, char * t){
int r[128];
int rs[128];
int i;
for(i=0;i<128;i++){
r[i]=-99;
rs[i]=0;
}
for(i=0;s[i]!='\0';i++){
int val=s[i]-t[i];
if(r[s[i]]==-99){
r[s[i]]=val;
rs[t[i]]++;
if(rs[t[i]]>1){
return false;
}
}
else{
if(r[s[i]]!=val){
return false;
}
}
}
return true;
}
边栏推荐
- 如何理解 Transformer 中的 Query、Key 与 Value
- Adobe Premiere基础-常用的视频特效(裁剪,黑白,剪辑速度,镜像,镜头光晕)(十五)
- SPuG - lightweight automatic operation and maintenance platform
- Cloud assisted privacy collection intersection (server assisted psi) protocol introduction: Learning
- Database query optimization: master-slave read-write separation and common problems
- Review of drug discovery-03-molecular design and optimization
- What is digitalization? What is digital transformation? Why do enterprises choose digital transformation?
- Arrays.asList()坑
- How to build an e-commerce platform at low cost
- Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)
猜你喜欢

什麼是數字化?什麼是數字化轉型?為什麼企業選擇數字化轉型?

Original | 2025 to achieve the "five ones" goal! The four products of Jiefang power are officially released

The practice of dual process guard and keeping alive in IM instant messaging development

Meituan dynamic thread pool practice idea has been open source

嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)

基于AM335X开发板 ARM Cortex-A8——Acontis EtherCAT主站开发案例

Interviewer asked: Inheritance of JS

Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data

SQL Server 2016 detailed installation tutorial (with registration code and resources)

【牛客讨论区】第四章:Redis
随机推荐
Cloud assisted privacy collection intersection (server assisted psi) protocol introduction: Learning
Lefse analyzes the local implementation method with all installation files and details to ensure success.
Adobe Premiere Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa
万字长文看懂商业智能(BI)|推荐收藏
Centos8 operation record command version Yum redis MySQL Nacos JDK
What is a through-hole conductive slip ring?
有监督、无监督与半监督学习
205. 同构字符串
Drug interaction prediction based on learning size adaptive molecular substructure
How to optimize the "message" list of IM
Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
Chapitre 4: redis
How about the market application strength of large-size conductive slip rings
Implementation of timed tasks in laravel framework
Is it safe to open an account online now? Novice is just on the road, ask for the answer
Why stainless steel swivel
Modular development
MapReduce elementary programming practice
Some problems in awk
药物发现综述-01-药物发现概述