Really easy solution


  • 0
    A
    class Solution {
    public:
        bool isAnagram(string s, string t) {
            vector<int> s_hash(26, 0), t_hash(26, 0);
            for(auto ch : s) {
                s_hash[ch-'a'] ++;
            }
            for(auto ch : t) {
                t_hash[ch - 'a']++;
            }
            return (s_hash == t_hash);
        }
    };
    

Log in to reply
 

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