• + 1 comment

    check&verify,responce there are some testcases not work

    long winningLotteryTicket(int tickets_count, char** tickets) {
        int *bitmasks = calloc(tickets_count, sizeof(int));
        //int len;
        int cnt = 0;
    
        for (int i = 0; i < tickets_count; ++i)
            for (int j = 0, len = strlen(tickets[i]); j < len; ++j)
                bitmasks[i] |= 1 << (tickets[i][j] - '0'); // set n-th bit to 1
    
        for (int i = 0; i < tickets_count; ++i)
            for (int j = i + 1; j < tickets_count; ++j)
                if ((bitmasks[i] | bitmasks[j]) == 1023)
                    ++cnt;
    
        return cnt;
    }