#C12848. Isomorphic Strings
Isomorphic Strings
Isomorphic Strings
Given two strings s1 and s2, determine if they are isomorphic. Two strings are isomorphic if there exists a one-to-one mapping between every character of s1 and every character of s2. Formally, there exists a bijective function \(f\) such that for every character \(x\) in s1, \(f(x)\) is the corresponding character in s2. Note that both strings must have the same length for such a mapping to exist.
For example, consider the strings "egg" and "add". The mapping \(e \to a\) and \(g \to d\) is consistent and one-to-one, so they are isomorphic. In contrast, the strings "foo" and "bar" are not isomorphic because the character 'o' in "foo" would have to map to two different characters ('a' and 'r') in "bar".
inputFormat
The input consists of two lines. The first line contains the string s1 and the second line contains the string s2. Both strings may be empty, and each string's length does not exceed typical limits.
outputFormat
Output a single line containing either True
if the two strings are isomorphic, or False
otherwise.
egg
add
True