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

Two strings are isomorphic if the characters in s can be replaced to get t.

All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character but a character may map to itself.

For example,
Given "egg""add", return true.

Given "foo""bar", return false.

Given "paper""title", return true.

题解:显然是哈希查找,但是其实没必要用map,一共就255个字符,每次只记录它现在的位置就好(因为之前的位置都比较过了)。

class Solution {
public:
bool isIsomorphic(string s, string t) {
int hs[]={};
int ht[]={};
int ls=s.length(),lt=t.length();
if(ls!=lt) return false;
for(int i=;i<ls;i++){
if(hs[s[i]]!=ht[t[i]]){
return false;
}
hs[s[i]]=i+;
ht[t[i]]=i+;
}
return true;
}
};

最新文章

  1. Nopcommerce 二次开发1 基础
  2. 3.1 ARM汇编编程概述
  3. CentOS下搭建SVN
  4. MongoDB:实体对象(javabean)转DBObject
  5. jquery中奖实例代码
  6. SCCM客户端推送/卸载
  7. 3529: [Sdoi2014]数表 - BZOJ
  8. djano-cms学习笔计(一)
  9. python高级编程:有用的设计模式3
  10. 重拾python
  11. React之ref详细用法
  12. Ubuntu 16.04 设置MySQL远程访问权限
  13. Oracle创建新undo表空间最佳实践(包含段检查)
  14. Linux系统上面使用python切割nginx日志
  15. Python RabbitMQ RPC实现
  16. Mac安装使用MongoDB
  17. Flume 在有赞大数据的实践
  18. vue前后分离动态路由和权限管理方案
  19. kali Rolling 安装QQ和虚拟机
  20. net-snmp 的配置

热门文章

  1. staitic_cast原理与使用
  2. java工程中当前目录在html中的设置
  3. 【CodeM初赛A轮】D 分解质因数+暴力
  4. android菜鸟学习笔记22----ContentProvider(二)ContentObserver的简单使用
  5. JVM虚拟机参数
  6. centos下安装pip时失败:
  7. MyEclipse2014新增bug,尝鲜的朋友需注意NotFoundException: org.springframework.web.context.ContextLoaderListener
  8. ubuntu vim退出时出错
  9. 说说JavaScript 中的new吧
  10. springboot5