


Two strings are isomorphic if a one-to-one mapping is possible for every character of the first string ‘str1’ to every character of the second string ‘str2’ while preserving the order of the characters.
All occurrences of every character in the first string ‘str1’ should map to the same character in the second string, ‘str2’.
If str1 = “aab” and str2 = “xxy” then the output will be 1. ‘a’ maps to ‘x’ and ‘b’ maps to ‘y’.
If str1 = “aab” and str2 = “xyz” then the output will be 0. There are two different characters in 'str1', while there are three different characters in 'str2'. So there won't be one to one mapping between 'str1' and 'str2'.
The first line contains the strings 'str1' and the next line contains the string 'str2'.
Print 1 if the two strings are isomorphic, else print 0.
The basic idea is to iterate through all the characters of str2 for every character of str1.
The steps are as follows:
The idea is to create a Hash array to store mappings of processed characters of str1 and another array to mark visited characters of str2.