LCC '21 Contest 3 S2 - Replacement Strings

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

Oscar has two strings of length N, string a and string b. He wonders the following question:

Is it possible to turn string a into string b by substituting all instances of one letter with another letter?

Input Specification

The first line of input contains an integer, N (1 \le N \le 2 \times 10^{6}). The second line of input contains a string, a. The third line of input contains a string, b.

Strings a and b will consist of lowercase letters only.

Output Specification

Output yes or no in response to Oscar's question.

Sample Input 1

5
enels
nnnls

Sample Output 1

yes

Explanation

If you replace all occurences of e in string a with n, you get string b.

Sample Input 2

5
enels
enenn

Sample Output 2

no

Explanation

There is no way to make string a the same as string b by replacing all instances of one letter with another. If you were to replace all instances of l with n, you would get the string enens. If you were to replace all instances of s with n, you would get the string eneln. Neither of these results equal the target string, enenn.

Sample Input 3

5
enels
ennls

Sample Output 3

no

Explanation

There is no way to make string a the same as string b by replacing all instances of one letter with another. If you were to replace all instances of e with n, you get the string nnnls, which doesn't equal the target string, ennls.


Comments

There are no comments at the moment.