Isomorphic Strings(C++) by yangchaojie


  • 0
    Y

    class Solution {
    public:
    bool isIsomorphic(string s, string t) {
    bool isIsomorphic = true;
    for(int i = 0;i < s.length();i++)
    {
    for(int j = i+1;j < s.length();j++)
    {
    if(s[i] == s[j])
    {
    if(t[i] != t[j])
    isIsomorphic = false;
    break;
    }
    else if(t[i] == t[j])
    {
    if(s[i] != s[j])
    isIsomorphic = false;
    break;
    }
    }
    }

        return isIsomorphic;
        
    }
    

    };


Log in to reply
 

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