Isomorphic Strings
Easy Accuracy: 27.01% Submissions: 4752 Points: 2

Given two string 'str1' and 'str2', check if two given strings are isomorphic to each other. Two strings str1 and str2 are called isomorphic if there is a one to one mapping possible for every character of str1 to every character of str2. And all occurrences of every character in ‘str1′ map to same character in ‘str2′.

Input:
The first line contains an integer T, depicting total number of test cases. Each test case contains two strings each in new line.

Output:
Print "1" if strings are isomorphic and "0" if not.

Constraints:
1 <= T <= 100
1 <= Length of Strings <= 103

Example:
Input:
2
aab
xxy
aab
xyz

Output:
1
0

Explanation:
Testcase 1:
There are two different characters in aab and xxy, i.e a and b with frequency 2 and 1 respectively.

 

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Output Window