Given two strings s and t, write a function to determine if t is an anagram of s.
For example,
s = “anagram”, t = “nagaram”, return true.
s = “rat”, t = “car”, return false.
class Solution {
public:
bool isAnagram(string s, string t) {
if(s.length() != t.length())
return false;
if(s=="" || t=="")
return true;
int count[26]={0};
for(int i = 0; i < s.length(); ++i){
count[s[i]-'a']++;
}
for(int i = 0; i < t.length(); ++i){
count[t[i]-'a']--;
}
for(int i = 0; i < 26; ++i)
if(count[i])
return false;
return true;
}
};