###### Easy-题目46：205. Isomorphic Strings

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.
Note:
You may assume both s and t have the same length..

public class Solution {
public boolean isIsomorphic(String s, String t) {
int slen=s.length();
int tlen=t.length();
if(slen!=tlen)
return false;
else
{
HashMap<Character,Character> map=new HashMap();
for(int i=0;i<slen;i++)
{
if(!map.containsKey(s.charAt(i)))
map.put(s.charAt(i),t.charAt(i));
else
{
if(map.get(s.charAt(i)) != t.charAt(i))
return false;
}
}
map.clear();
for(int i=0;i<slen;i++)
{
if(!map.containsKey(t.charAt(i)))
map.put(t.charAt(i),s.charAt(i));
else
{
if(map.get(t.charAt(i)) != s.charAt(i))
return false;
}
}
return true;
}
}
}

34ms,beats 30.09%,众数26ms，8.93%

#### 205. Isomorphic Strings [easy] (Python)

2016-06-15 14:02:47

#### LeetCode 205:Isomorphic Strings

2015-05-08 23:06:25

#### LeetCode 205. Isomorphic Strings（C++版）

2017-03-31 10:54:17

#### leetcode 205: Isomorphic Strings

2015-04-30 04:54:59

#### 【LeetCode】205 Isomorphic Strings （c++实现）

2015-07-22 10:29:55

#### 【LeetCode-面试算法经典-Java实现】【205-Isomorphic Strings（同构字符串）】

2015-08-27 06:33:32

#### 【LeetCode-205】Isomorphic Strings(C++)

2016-09-09 22:40:50

#### Leetcode_205_Isomorphic Strings

2015-06-17 10:27:44

#### [leetcode-205]Isomorphic Strings(java)

2015-08-26 19:35:56

#### Leetcode 205 Isomorphic Strings 同构字符串

2015-08-07 18:21:45

## 不良信息举报

Easy-题目46：205. Isomorphic Strings