Here is the leetcode problem link : valid-anagram
It is giving WA in
“a”
“b”
class Solution {
public:
bool isAnagram(string s, string t)
{
if(s.length() != t.length())
return false;
int count[256]={};
for(int i=0;i<s.length()-1;i++)
count[s[i]-'a']++;
for(int i=0;i<t.length()-1;i++)
count[t[i]-'a']--;
for(int i=0;i<256;i++)
if(count[i] != 0)
return false;
return true;
}
};