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的更多相关文章

  1. LeetCode——Add Strings

    LeetCode--Add Strings Question Given two non-negative integers num1 and num2 represented as string, ...

  2. [LeetCode] Add Strings 字符串相加

    Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. ...

  3. [LeetCode] Isomorphic Strings 同构字符串

    Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the chara ...

  4. [LeetCode] Multiply Strings 字符串相乘

    Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...

  5. LeetCode Add Strings

    原题链接在这里:https://leetcode.com/problems/add-strings/ 题目: Given two non-negative numbers num1 and num2  ...

  6. [LeetCode] Buddy Strings 伙计字符串

    Given two strings A and B of lowercase letters, return true if and only if we can swap two letters i ...

  7. [leetcode]Multiply Strings @ Python

    原题地址:https://oj.leetcode.com/problems/multiply-strings/ 题意: Given two numbers represented as strings ...

  8. LeetCode:Multiply Strings

    题目链接 Given two numbers represented as strings, return multiplication of the numbers as a string. Not ...

  9. [LeetCode] Isomorphic Strings

    Isomorphic Strings Total Accepted: 30898 Total Submissions: 120944 Difficulty: Easy Given two string ...

随机推荐

  1. Oracle_双机备份

    1.dataguard http://jingyan.baidu.com/article/f96699bb956ef2894e3c1b39.html http://blog.itpub.net/262 ...

  2. Java通过jedis操作redis缓存

    package com.wodexiangce.util; import java.util.Set; import redis.clients.jedis.Jedis; /** * redis工具类 ...

  3. 转:从编译链接过程解析static函数的用法

    关于static函数的用法 就像我们熟知的那样,变量可以分全局的和局部的,函数也可以分全局的和局部的. 比如说,在一个工程的common.h中定义了一个全局变量 int test;那么在整个工程的作用 ...

  4. bootstrap之消息提示

    <!DOCTYPE html><html>   <head>      <title>Bootstrap</title>      < ...

  5. 读javascript高级程序设计08-引用类型之Global、Math、String

    一.Global 所有在全局作用域定义的属性和方法,都属于Global对象. 1.URI编码: encodeURI():主要用于对整个URI编码.它不会对本身属于URI的特殊字符进行编码. encod ...

  6. Python 代码优化常见技巧

    代码优化能够让程序运行更快,它是在不改变程序运行结果的情况下使得程序的运行效率更高,根据 80/20 原则,实现程序的重构.优化.扩展以及文档相关的事情通常需要消耗 80% 的工作量.优化通常包含两方 ...

  7. iOS开发拓展篇—音频处理(音乐播放器3)

    iOS开发拓展篇—音频处理(音乐播放器3) 说明:这篇文章主要介绍音频工具类和播放工具类的封装. 一.控制器间数据传递 1.两个控制器之间数据的传递 第一种方法:self.parentViewCont ...

  8. css盒子模型 padding

    注意: 行内元素的内边距的top和bottom是不起作用的,想让他起作用要让他变成块元素加:display:bloock 注意: 如果元素设置了背景,那么背景会填充到内容区+内边距区 利用paddin ...

  9. .gitignore

    # Xcode # build/ *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *. ...

  10. vbs常用代码

    在网上查找资料的时候发现好多经典的vbs代码收集起来也为了以后学习. VBS播放音乐 Dim wmp Set wmp = CreateObject("WMPlayer.OCX") ...