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 ...
随机推荐
- ie6兼容之绝对定位元素内容为空时高度问题
正常显示: ie6下显示: line6元素高度最小16px; 解决办法: 添加内容在空的div里,并且设置行高即可. 其中,非ie6浏览器不需要再空的div里加无谓的内容,再次需要用“条件注释”来解决 ...
- ios 模拟器不显示系统版本了,后边都是 uuid 了,怎么弄回来?系统升级xcode6.4,模拟器找不到选择了?
当我用El Capitan Beta 下 Xcode6.4版本时候出现了问题 常用的Scheme 选择版本不见了 而在Xcode 7.0 beta 6中显示有 简直就是坑,经过查资料其实是一个bug ...
- javascript模仿php 函数 trim ltrim rtrim (原创)
javascript模仿php 函数 trim ltrim rtrim,去除字符串两边空格或其他符号 本文地址:js trim js php trim function trims(){ this. ...
- css代码段
css文字超出省略 .demo{ display:-webkit-box; overflow:hidden; text-overflow:ellipsis; -webkit-line-clamp:2; ...
- eclipse中新建jni工程
1.什么是NDK 网上很多不多说,全称是Android Native Developer Kit,是一个工具合集,我理解可以把c/c++打包成.so文件 这是目录结构,要用到指令ndk-build 需 ...
- laravel 控制器方法里存get值 和 blade 模板获得闪存值的方法
//get 方式把id传到路由 <a href="/admin/reply/add/{{$comment -> id}}" class="btn btn-bl ...
- 【CSS3】标签使用说明
转换(transform):改变元素的形状.大小和位置. transform:rotate(20deg):顺时针旋转20° rotate()用来2D旋转改变角度.支持负数,表示逆时针. transfo ...
- 转 Android开发笔记(成长轨迹)
http://blog.csdn.net/mad1989/article/details/9142557
- 2014-07-29 Asp.Net 中级工程师 笔试题
一.选择题 1.下列描述错误的是() A 类不可以被多重继承而接口可以: B 抽象类自身可以定义成员而接口不可以: C 抽象类和接口都不能被实例化: D 一个类可以继承多个基类和多个基 ...
- OC语言构造方法
OC语言构造方法 一.构造方法 (一)构造方法的调用 完整的创建一个可用的对象:Person *p=[Person new]; New方法的内部会分别调用两个方法来完成2件事情,1)使用alloc方法 ...