Valid Anagram

2017/12/9 posted in  leetcode

class Solution {
public:
    bool isAnagram(string s, string t) {
        if (s.length() != t.length()) return false;
        unordered_map<char, int> map;
        for (int i =0; i<s.length(); i++) {
            map[s[i]]++;
            map[t[i]]--;
        }
        for(auto s:map){
            if(s.second<0) return 0;
        }
        return 1;
    }
};