classSolution{publicbooleanisIsomorphic(String s,String t){int[] map1 =newint[128];// index represents character ASCIIint[] map2 =newint[128];// Loop through all the charactersfor(int i =0; i < s.length();++i){// compare characterif(map1[s.charAt(i)]!= map2[t.charAt(i)]){returnfalse;}// Assign position num to each character// +1 is to avoid 0 which is the default value of every position
map1[s.charAt(i)]= i+1;
map2[t.charAt(i)]= i+1;}returntrue;}}