天天看點

[LeetCode] 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 <code>"egg"</code>,<code>"add"</code>, return <code>true</code>.

given <code>"foo"</code>, <code>"bar"</code>, return <code>false</code>.

given <code>"paper"</code>, <code>"title"</code>, return <code>true</code>.

note:

you may assume both s and t have the same length.

建立兩個表:

①從字元串s到字元串t的字元映射表,因為最大的字母為122,是以映射表的大小為123。映射表鍵值為s中的字元,value為t中對應位置的字元。

②isused表代表t中的該字元是否已經被作為s中某字元的value值。