#C8762. String Transformation
String Transformation
String Transformation
You are given two strings S
and T
consisting of lowercase English letters. Your task is to determine whether it is possible to transform S
into T
by applying a bijective character mapping. In other words, you need to check if there exists a one-to-one correspondence (a bijection) f such that for every valid index i,
The transformation is only possible if the following conditions hold:
- The lengths of
S
andT
are equal, i.e. $$|S| = |T|.$$ - Each character in
S
consistently maps to the corresponding character inT
and no two different characters inS
map to the same character inT
(ensuring the mapping is bijective).
If both conditions are satisfied, output YES
; otherwise, output NO
.
Note: The constraints are $$1 \leq |S|, |T| \leq 10^5$$.
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains the string
S
. - The second line contains the string
T
.
outputFormat
Output a single line to stdout containing YES
if it is possible to transform S
into T
using a bijective mapping, or NO
if it is not possible.
abc
def
YES