My 8 lines C++ easy and clean solution

  • 3
        bool isIsomorphic(string s, string t) {
            int ss[256]={0};
            int tt[256]={0};
            for(int i=0;i<s.length();i++)
                if(ss[s[i]]!=tt[t[i]]) return false;
                ss[s[i]] = i+1;
                tt[t[i]] = i+1;
            } return true;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.