19ms simple easy C++ solution


  • 0
    X
    public:
        bool isAnagram(string s, string t) {
            
            map<char, int> m1, m2;
    
            for(auto x : s)
                m1[x]++;
            
            for(auto x : t)
                m2[x]++;
    
            if(m1 == m2) 
                return true;
            else 
                return false;
            
        }
    };

Log in to reply
 

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