C++ simple solution


  • 0
    C

    class Solution {
    public:
    bool isIsomorphic(string s, string t)
    {
    char a[255] = {0};
    char b[255] = {0};
    int i = 0;
    for(i = 0;i<s.size();i++)
    {
    a[s[i]] = t[i];
    b[t[i]] = s[i];
    }
    for(i = 0;i<s.size();i++)
    {
    if(a[s[i]]!=t[i] || b[t[i]]!=s[i])
    {
    return false;
    }
    }
    return true;
    }
    };


Log in to reply
 

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