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;
}
};
Valid Anagram
Copyright © 2017 Powered by LZH, Theme used GitHub CSS.