638.Strings Homomorphism
1.Description(Easy)
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.
Notice
You may assume both s and t have thesame length.
Example
Given s ="egg", t ="add", returntrue.
Given s ="foo", t ="bar", returnfalse.
Given s ="paper", t ="title", returntrue.
2.Code
Solution 1:
判断对应位置字符是否成唯一映射,同时判断是否出现重复映射。
Solution 2:
Last updated
Was this helpful?