문제 링크 : Isomorphic Strings
/**
* @param {string} s
* @param {string} t
* @return {boolean}
*/
var isIsomorphic = function(s, t) {
let sArr = new Array(26).fill(0);
let tArr = new Array(26).fill(0);
for(let i=0; i<s.length; i++) {
const sIdx = s[i].charCodeAt(0) - 97
const tIdx = t[i].charCodeAt(0) - 97
sArr[sIdx] += 1
tArr[tIdx] += 1
}
return sArr.filter(el => el !== 0).sort((a,b) => a-b).join('') === tArr.filter(el =>el!==0).sort((a,b) => a-b).join('') ? true : false
};
/**
* @param {string} s
* @param {string} t
* @return {boolean}
*/
var isIsomorphic = function(s, t) {
let sStr = ''
let tStr = ''
for(let i=0; i<s.length; i++) {
sStr = s.indexOf(s[i])
tStr = t.indexOf(t[i])
if(sStr !== tStr) return false
}
return true
};