Write a method to decide if two strings are anagrams or not.
思路:使用一个count记录每个字符出现的次数,若出现的次数都相同,说明两个词是变位词
bool isStringAnagrams(char s[],char t[]){
if(s==NULL||t==NULL||strlen(s)!=strlen(t))
return false;
int count[256];
memset(count,0,sizeof(count));
for(int i=0,len=strlen(s);i<len;i++){
count[s[i]]++;
count[t[i]]--;
}
for(int i=0;i<256;i++)
if(count[i]!=0)
return false;
return true;
}
答案解法中的return i==len-1有些理解?????