【leetcode】 数组中的字符串匹配

char ** stringMatching(char ** words, int wordsSize, int* returnSize){
    char** arr = (char**)calloc(wordsSize,sizeof(char*));
    int n =0;
    for (int i=0; i<wordsSize; i++)
    {
        for (int j=0; j<wordsSize; j++)
        {
            if (i == j) continue;
            if (strstr(words[j],words[i])) 
            {
                arr[n++] = words[i];
                break;
            }
        }
    }
    *returnSize = n;
    return arr;
}
原文地址:https://www.cnblogs.com/ganxiang/p/13613933.html