hi,it is a good article.but it has a problem:
Q20:
for your function ,it seemed wrong:
isIsomorphic('sad', 'egg') !== isIsomorphic('egg', 'sad')
my function:
function isIsomorphic(stra, strb) {
if (typeof stra === 'string' && typeof strb === 'string') {
const len = stra.length;
if (len !== strb.length) {
return false;
}
const mapa = {};
const mapb = {};
function countApperTimes(map, pro) {
map[pro] = map[pro] ? map[pro] + 1 : 1;
}
for (let i = 0; i < len; i++) {
const a = stra[i];
const b = strb[i];
countApperTimes(mapa, a);
countApperTimes(mapb, b);
if (mapa[a] !== mapb[b]) {
return false;
}
}
return true;
}
return false;
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
hi,it is a good article.but it has a problem:
Q20:
for your function ,it seemed wrong:
isIsomorphic('sad', 'egg') !== isIsomorphic('egg', 'sad')
my function: