bool isAnagram(string s, string t) {
int alp[26]={};
for (int i = 0; i < s.length(); i++)
alp[s.at(i)  'a']++;
for (int i = 0; i < t.length(); i++)
alp[t.at(i)  'a'];
for (int i=0;i<26;i++)
if (alp[i] != 0)
return false;
return true;
}
0ms C++solution,O(n)time

alp[26]={} means every element is 0, like alp[26]={0}. if you do not initialize this array, the element may not be 0, if the test string do not contain the 26 different letters, some elements in the array alp may not change. so the judge statement if (alp[i] != 0) could not make the right judgment.

bool isAnagram(string s, string t) {
unordered_map<char,int> Mymap; int m=s.length(); int n=t.length(); if(m!=n) return false; for(int i=0;i<m;i++) { if(Mymap.find(s[i])==Mymap.end()) Mymap[s[i]] = i+100; else Mymap[s[i]] += 100; } for(int i=0;i<n;i++) { if(Mymap.find(t[i])==Mymap.end()) return false; else if((Mymap[t[i]] = 100)<0) return false; } return true;