int getRes(char *str){ int len = strlen(str); char c = 'z'; int ht[26] = {0}; for(int i=0; i<len; i++){ ht[str[i]-'a']++; c = str[i] < c ? str[i] : c; } return ht[c-'a']; } int* numSmallerByFrequency(char ** queries, int queriesSize, char ** words, int wordsSize, int* returnSize){ int ht[11] = {0}, i; for(i=0; i<wordsSize; i++){ int times; times = getRes(words[i]); ht[times]++;//HASH一次 } for(i=1; i<11; i++) ht[i]+=ht[i-1]; int *ans = (int*)calloc(queriesSize, sizeof(int)); *returnSize = queriesSize; for(i=0; i<queriesSize; i++){ int times = getRes(queries[i]); ans[i] = ht[10]-ht[times];//HASH三次 } return ans; }