###### [leetcode 205] Isomorphic Strings

Question:

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.

<span style="font-size:14px;">class Solution {
public:
bool isIsomorphic(string s, string t) {
/*unordered_map<char,char> unordmap1, unordmap2;
if(s.length() != t.length())
return false;
for(int i = 0; i < s.length(); ++i){
if(unordmap1.find(s[i]) == unordmap1.end())
unordmap1[s[i]] = t[i];
else{
if(t[i] != unordmap1[s[i]])
return false;
}
if(unordmap2.find(t[i]) == unordmap2.end())
unordmap2[t[i]] = s[i];
else{
if(s[i] != unordmap2[t[i]])
return false;
}
}
return true;*/

if (check(s, t) && check(t,s))
return true;
else
return false;
}
bool check(string s, string t) {
int dict[256];
fill_n(dict, 256, 0);
for (int i=0; i<s.length(); i++)
if (dict[s[i]]==0) dict[s[i]]=t[i];
else if (dict[s[i]] != t[i])
return false;
return true;
}
};</span>

#### LeetCode 205:Isomorphic Strings

2015-05-08 23:06:25

#### leetcode 205: Isomorphic Strings

2015-04-30 04:54:59

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

2015-07-22 10:29:55

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

2016-09-09 22:40:50

#### leetcode_c++：哈希： Isomorphic Strings(205)

2016-07-10 14:18:42

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

2015-08-27 06:33:32

#### 【leetcode】205. Isomorphic Strings（Python & C++）

2017-08-25 21:27:15

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

2015-08-26 19:35:56

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

2016-06-15 14:02:47

#### 关于LeetCode中Isomorphic Strings一题的理解

2016-09-07 18:31:53

## 不良信息举报

[leetcode 205] Isomorphic Strings