## 题目描述：

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.

## 解题思路：

`sourceMap[ t[x] ]` = `s[x]`

`targetMap[ s[x] ]` = `t[x]`

## Python代码：

``````class Solution:
# @param {string} s
# @param {string} t
# @return {boolean}
def isIsomorphic(self, s, t):
sourceMap, targetMap = dict(), dict()
for x in range(len(s)):
source, target = sourceMap.get(t[x]), targetMap.get(s[x])
if source is None and target is None:
sourceMap[t[x]], targetMap[s[x]] = s[x], t[x]
elif target != t[x] or source != s[x]:
return False
return True
``````

Pingbacks已关闭。