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 ...
随机推荐
- 深入浅出设计模式——访问者模式(Visitor Pattern)
模式动机 对于系统中的某些对象,它们存储在同一个集合中,且具有不同的类型,而且对于该集合中的对象,可以接受一类称为访问者的对象来访问,而且不同的访问者其访问方式有所不同,访问者模式为解决这类问题而诞生 ...
- [Mysql] 一些记录
1> 修改表的字段 alter table trade_market change reqype reqtype int(10) unsigned not null;alter table tr ...
- python核心编程第六章练习6-15
转换.(a)给出两个可识别格式的日期,比如MM/DD/YY或者DD/MM/YY格式.计算出两个日期之间的天数.(b)给出一个人的生日,计算此人从出生到现在的天数,包括所有的闰月.(c)还是上面的例子, ...
- setInterval和setTimeout的区别
setInterval会每隔指定的毫秒数后反复执行指定代码. setTimeout只会在指定的毫秒数后执行一次指定代码. setInterval的用法: // 创建(创建后即开始计时) var int ...
- 51nod 1027大数乘法
题目链接:51nod 1027大数乘法 直接模板了. #include<cstdio> #include<cstring> using namespace std; ; ; ; ...
- 51nod 1158 全是1的最大子矩阵
题目链接:51nod 1158 全是1的最大子矩阵 题目分类是单调栈,我这里直接用与解最大子矩阵类似的办法水过了... #include<cstdio> #include<cstri ...
- mousedown(function(){ return false; })作用
mousedown(function(){ return false;}); 阻止浏览器的默认行为. 比如a你加个空连接,可能会在当前页跳转, 你加了这句,就可以阻止a跳转,然后只执行js函数的代 ...
- Python学习笔记----序列共性
序列操作符 作用seq[ind] 获得下标为ind 的元素seq[ind1:ind2] 获得下标从ind1 到ind2 间的元素集合seq * expr 序列重复expr 次seq1 + seq2 连 ...
- $.post 请求一直转圈圈,谷歌浏览器状态一直为canceled
最开始写的是 $.post("url",{},function(){},"json") 用火狐浏览器 测试发现请求一直在转圈圈 ,就在action输出 发现也进 ...
- iOS开发拓展篇—UIDynamic(简单介绍)
iOS开发拓展篇—UIDynamic(简单介绍) 一.简单介绍 1.什么是UIDynamic UIDynamic是从iOS 7开始引入的一种新技术,隶属于UIKit框架 可以认为是一种物理引擎,能模拟 ...