algorithms/strings/gem-stones.c
int gemstones(int arr_count, char** arr) {
    int total[26];
    memset(total, 0, sizeof(total));
    for (int i = 0; i < arr_count; i++) {
        int count[26];
        char *stone = arr[i];
        memset(count, 0, sizeof(count));
        for (int j = 0; stone[j]; j++) {
            count[stone[j] - 'a'] = 1;
        }
        for (int k = 0; k < 26; k++) {
            total[k] += count[k];
        }
    }
    int gems = 0;
    for (int k = 0; k < 26; k++) {
        if (total[k] == arr_count) {
            gems++;
        }
    }
    return gems;
}
// Complete the gemstones function below.
Complete the gemstones function below.
Complete the gemstones function below .
int gemstones(int arr_count, char** arr) {
    int total[26];
    memset(total, 0, sizeof(total));
    for (int i = 0; i < arr_count; i++) {
        int count[26];
        char *stone = arr[i];
        memset(count, 0, sizeof(count));
        for (int j = 0; stone[j]; j++) {
            count[stone[j] - 'a'] = 1;
        }
        for (int k = 0; k < 26; k++) {
            total[k] += count[k];
        }
    }
    int gems = 0;
    for (int k = 0; k < 26; k++) {
        if (total[k] == arr_count) {
            gems++;
        }
    }
    return gems;
}
int gemstones ( int arr_count , char * * arr ) { int total [ 26 ] ; memset ( total , 0 , sizeof ( total ) ) ; for ( int i = 0 ; i < arr_count ; i ++ ) { int count [ 26 ] ; char * stone = arr [ i ] ; memset ( count , 0 , sizeof ( count ) ) ; for ( int j = 0 ; stone [ j ] ; j ++ ) { count [ stone [ j ] - ' ' ] = 1 ; } for ( int k = 0 ; k < 26 ; k ++ ) { total [ k ] += count [ k ] ; } } int gems = 0 ; for ( int k = 0 ; k < 26 ; k ++ ) { if ( total [ k ] == arr_count ) { gems ++ ; } } return gems ; }
Complete the gemstones function below.
Complete the gemstones function below .