Skip to main content

Leetcode - 205. Isomorphic Strings

· One min read

https://leetcode.com/problems/isomorphic-strings/

Solution1

/**
* @param {string} s
* @param {string} t
* @return {boolean}
*/
var isIsomorphic = function (s, t) {
if (s.length !== t.length) {
return false;
}

if (s === t) {
return true;
}

for (let i = 0; i < s.length; i++) {
if (s.indexOf(s[i]) !== t.indexOf(t[i])) {
return false;
}
}
return true;
};