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有些理解?????