467. Determine if Two Strings Are Close
MediumCounting
You may swap any two characters, or transform every occurrence of one existing letter into another existing letter and vice versa. Print YES if word1 can become word2, else NO.
Input format
Line 1: word1 Line 2: word2
Output format
YES or NO
Example 1
Input
abc bca
Output
YES
Example 2
Input
a aa
Output
NO
Constraints
1 ≤ lengths ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…