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 ...
随机推荐
- Keycode对照表
字母和数字键的键码值(keyCode) 按键 键码 按键 键码 按键 键码 按键 键码 A 65 J 74 S 83 1 49 B 66 K 75 T 84 2 50 C 67 L 76 U 85 3 ...
- 【转载】CSS规范
原文地址:http://www.cnblogs.com/whitewolf/p/4491707.html 目录 HTML 语法 HTML5 doctype 语言属性(Language attribut ...
- window.onload()和$(function(){});的区别
1.window.onload必须等到页面中所有元素加载完之后才会执行(包括图片.视频等)而$(function(){});是在结构绘制完毕之后执行,二者的执行时机是不同的,一般来说后者会首先执行 2 ...
- lhgdialog: iframe页面里面的,确定,关闭、取消按钮的操作
lhgdialog: iframe页面里面的,确定,关闭.取消按钮的操作 如果你正在用lhgdialog,用他人iframe,或者 content:'url:http://www.baidu.com/ ...
- b.Connector配置解析
前面讲解到Tomcat中使用Digester框架进行server.xml到javaBean对象的映射,这篇文章以Connector的SSL通道为例,来讲解Connector的属性是如何注入的. 先看一 ...
- px和em
相同点: 都是长度单位 不同点: px是绝对单位,不支持IE的缩放,em是相对单位. px的值是固定的,指定是多少就是多少:em得值不是固定的,并且em会继承父级元素的字体大小 ps: 浏览器的默认字 ...
- 最短路径——Floyd算法
如何求一张图中任意两顶点之间的最短路径长度,这里写一种最简单的算法——Floyd算法: #include<stdio.h> #define inf 9999 int main() { ][ ...
- "编写高质量代码"一书笔记
总结 css架构结构 : base : 共用样式 common: 通用控件样式 page: 页面级样式 js 架构结构: base 位于三层最底层,职责一是封装不同浏 ...
- apache开启.htaccess
1 . 如何让的本地APACHE开启.htaccess 如何让的本地APACHE开启.htaccess呢?其实只要简朴修改一下apache的httpd.conf设置就让APACHE.htaccess了 ...
- iOS基础篇(十七)——UIGestureRecognizer用法
UIGestureRecognizer(手势识别)在iOS 中非常重要,他极大地提高了移动设备的使用便捷性: 在3.2之前是主要使用的是由UIResponder而来的如下4种方式: - (void)t ...