Extremely clean and concise solution


  • 0
    X
    class Solution {
    public:
        bool isIsomorphic(string s, string t) 
        {
            vector<int> ss(256,-1),tt(256,-1);
            for(int i=0;i<s.size();i++)
            {
                if(ss[s[i]]!=tt[t[i]])
                    return false;
                ss[s[i]]=i,tt[t[i]]=i;
            }
            return true;
        }
    };
    

Log in to reply
 

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