Valid Anagram
原题链接Valid Anagram
实际上就是判断两个字符串中每个字符出现的个数是否相等,直接计算每个字符的个数就可以了。
class Solution {
public:
bool isAnagram(string s, string t) {
unordered_map<char, int> shash;
unordered_map<char, int> thash;
for(auto ch : s)
++shash[ch];
for(auto ch : t)
++thash[ch];
if(shash.size() != thash.size())
return false;
for(auto it = shash.begin(); it != shash.end(); ++it)
{
if</