Say we have 2 strings
for the result to be true, one letter in the first string must have an unique mapping to one letter in the other string.
And the number of such mapping should be the SAME as the number of different letters in the 2 strings.
And that is all we need to check.
class Solution(object): def isIsomorphic(self, s, t): """ :type s: str :type t: str :rtype: bool """ return len(set(s)) == len(set(zip(s, t))) == len(set(t))
Explanation added. Hope it would help!
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.