Two strings are called isomorphic if one-to-one mapping is possible for every character of the first string to every character of the second string.
Sample Input:
s1 = “feel”, s2 = “moon”
Sample Output:
True
In above sample input, letter f is mapped to m, e is mapped to o, and l is mapped to n. So the two words are isomorphic strings.
数据结构和算法:初级练习题 #15 – 同构词
给定两个字符串s1和s2,如果第一个字符串的每个字符到第二个字符串的每个字符都有一对一的映射,那么这两个字符串称为同构词。
输入样例:
s1 = ”feel”, s2=”moon”
输出样例:
True
上面的输入样例中,字母 f 映射到 m,字母 e 映射到 o,字母 l 映射到n,所以这两个单词就是同构词。