#K42582. Isomorphic Strings
Isomorphic Strings
Isomorphic Strings
Given two strings \(s_1\) and \(s_2\), determine whether they are isomorphic. Two strings are isomorphic if there exists a one-to-one mapping between every character in \(s_1\) and every character in \(s_2\). In other words, if \(|s_1| \neq |s_2|\), they are not isomorphic. Otherwise, for each corresponding pair of characters, a consistent bijective mapping must hold.
For example, egg
and add
are isomorphic because the mapping \(e \to a, g \to d\) holds, whereas foo
and bar
are not isomorphic.
Your task is to process multiple test cases. Each test case consists of a pair of strings. For every test case, output Yes
if the strings are isomorphic and No
otherwise.
inputFormat
The input is read from standard input and consists of multiple test cases. The first line contains an integer \(T\) (\(T \geq 1\)), representing the number of test cases. Each of the following \(T\) lines contains two strings separated by a space.
outputFormat
For each test case, output one line containing either Yes
(if the strings are isomorphic) or No
(if they are not).
3
egg add
foo bar
paper title
Yes
No
Yes
</p>