Simple c code to solve isomorphic


  • 1
    bool isIsomorphic(char* s, char* t) 
    {
        int ha[256] = {0}, hb[256] = {0}, i = 0;
        for (i = 0; s[i] != '\0'; i++)
        {
            if (ha[s[i]] != hb[t[i]])
                return false;
            ha[s[i]] = i + 1;
            hb[t[i]] = i + 1;
        }
        return t[i] == '\0'; 
    }

Log in to reply
 

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