【leetcode】拼写单词

int countCharacters(char ** words, int wordsSize, char * chars){
    int hash[26]={0},arr[26]={0},i,j,sum=0,len;
    for (i=0; chars[i] != ''; i++)
        hash[chars[i]-'a']++;
    for (i=0; i<wordsSize; i++)
    {
        memcpy(arr,hash,26*sizeof(int));
        len = strlen(words[i]);
        for (j=0; j<len; j++)
            if (arr[words[i][j] - 'a']-- <1) break;
        if (j==len)
            sum += j;
    }
    return sum;
}
原文地址:https://www.cnblogs.com/ganxiang/p/13745229.html