LeetCode() Issomorphic Strings
bool isIsomorphic(string s, string t) {
int size=s.size();
if (size==0)
return true;
char ch[128],ismap[128];
for(int i=0;i<128;i++)
{`enter code here`
ch[i]=-1;
ismap[i]=-1;
}
bool flag=true;
for(int i=0;i<size;i++)
{
if(ch[s[i]]==-1&&ismap[t[i]]==-1)
{
ch[s[i]]=t[i];
ismap[t[i]]=s[i];
}else if(ch[s[i]]!=t[i]||ismap[t[i]]!=s[i])
{
flag=false;
break;
}
}
return flag;
}
我还是很难理解这样的思想。我的88ms的就不贴了
LeetCode() Issomorphic Strings的更多相关文章
- LeetCode——Add Strings
LeetCode--Add Strings Question Given two non-negative integers num1 and num2 represented as string, ...
- [LeetCode] Add Strings 字符串相加
Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. ...
- [LeetCode] Isomorphic Strings 同构字符串
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the chara ...
- [LeetCode] Multiply Strings 字符串相乘
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...
- LeetCode Add Strings
原题链接在这里:https://leetcode.com/problems/add-strings/ 题目: Given two non-negative numbers num1 and num2 ...
- [LeetCode] Buddy Strings 伙计字符串
Given two strings A and B of lowercase letters, return true if and only if we can swap two letters i ...
- [leetcode]Multiply Strings @ Python
原题地址:https://oj.leetcode.com/problems/multiply-strings/ 题意: Given two numbers represented as strings ...
- LeetCode:Multiply Strings
题目链接 Given two numbers represented as strings, return multiplication of the numbers as a string. Not ...
- [LeetCode] Isomorphic Strings
Isomorphic Strings Total Accepted: 30898 Total Submissions: 120944 Difficulty: Easy Given two string ...
随机推荐
- caller和callee属性
ECMAScript5规范了函数对象的属性:caller.除了Opera的早期版本不支持,其他浏览器都支持这个ECMAScript3并没有定义的属性. [IE,Firefox,Chrome,Safar ...
- python __file__ 与argv[0]
在python下,获取当前执行主脚本的方法有两个:sys.argv[0]和__file__. sys.argv[0] 获取主执行文件路径的最佳方法是用sys.argv[0],它可能是一个相对路径,所以 ...
- (三)kafka集群扩容后的topic分区迁移
kafka集群扩容后的topic分区迁移 kafka集群扩容后,新的broker上面不会数据进入这些节点,也就是说,这些节点是空闲的:它只有在创建新的topic时才会参与工作.除非将已有的partit ...
- aws在线技术峰会笔记-电商解决方案
Redshift PB级别的数据仓库
- Android ListView简单实用
layout创建: activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ ...
- 推荐10个bootstrap及其他框架的后台管理模板
相对于网站前台炫目多彩的设计,网址后台的设计模板貌似有点少,在这里推荐10个可以免费下载的~ 1.自适应超酷整站 win8风格的Bootstrap响应式网站后台管理模板-Apricot 2.boots ...
- (九)errno和perror、标准IO
3.1.6.文件读写的一些细节3.1.6.1.errno和perror(1)errno就是error number,意思就是错误号码.linux系统中对各种常见错误做了个编号,当函数执行错误时,函数会 ...
- 根据屏幕的宽度使用不同的css-文件
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- update 多表
update energylog set value=(a.value+c.value)/2from energylog as a, energylog as cwhere a.idvariable= ...
- debian开机启动管理
debian开机启动管理(转文) linux下,services的启动.停止等通常是通过/etc/init.d的目录下的脚本来控制的.在启动或改变运行级别是在/etc/rcX.d中来搜索脚本.其中X是 ...