Isomorphic Strings
来源:互联网 发布:博拉网络上市最新消息 编辑:程序博客网 时间:2024/04/30 17:29
public class Solution { public boolean isIsomorphic(String s, String t) { if (s == null || t == null) { return false; } char[] ss = s.toCharArray(); char[] tt = t.toCharArray(); int length = ss.length; HashMap<Character, Integer> map1 = new HashMap<Character, Integer>(); HashMap<Character, Integer> map2 = new HashMap<Character, Integer>(); for (int i = 0; i < length; i++) { if (map1.containsKey(ss[i])) { int loc = map1.get(ss[i]); if (tt[i] != tt[loc]) { return false; } } else { if (map2.containsKey(tt[i])) { return false; } } map1.put(ss[i], i); map2.put(tt[i], i); } return true; }}
0 0
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Isomorphic Strings
- Ruby社区应该去Rails化了
- 一个封装Volley框架的帮助类
- day03--面向对象---final关键字
- 微博信息发布方法、服务器及存储介质
- 多线程间的通讯之等待唤醒机制
- Isomorphic Strings
- C++之多态性与虚函数
- PLSQL连接远程ORACLE数据库中文乱码解决
- uva 10254(四柱汉诺塔)
- bank第二版
- Android HAL层hardware module的设计
- iOS 带参数函数体和不带参数函数体的实现与xcode单步调试
- 使用hydra暴力破解web登录界面
- android studio安装