DEV Community

Discussion on: Algorithm 101 (Interview Question): 2 Ways to Determine if 2 Words are Isomorphic

Collapse
 
ganeshshetty195 profile image
Ganesh Shetty

function isIsomorphic(str1, str2) {
var array = [];
var obj = {};
for (i = 0; i < str1.length; i++) {
if (!obj[str1[i]]) {
obj[str1[i]] = str2[i];
} else {
if (obj[str1[i]] !== str2[i]) {
console.log("NO ISOMORPHIC");
}
}
}
console.log(obj);
}
isIsomorphic("aab", "xyz");