# HackerRank Winning Lottery Ticket problem solution

In this HackerRank Winning Lottery Ticket problem solution, Your task is to find the number of winning pairs of distinct tickets, such that concatenation of their ticket IDs (in any order) makes for a winning scenario. Complete the function winningLotteryTicket which takes a string array of ticket IDs as input, and returns the number of winning pairs.

## Problem solution in Python.

```n = int(input())
p = [input().strip() for _ in range(n)]

for s in p:
for c in s:
mask |= 1 << (ord(c) - ord('0'))

res = 0
if i | j == fullMask:

print(int(res))
```

## Problem solution in C++.

```
#include "bits/stdc++.h"
using namespace std;
const int N = 1e6 + 6;
int n;
int cnt[1 << 10];

ios_base :: sync_with_stdio(false);
cin.tie(NULL);
string x;
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> x;
for(int j = 0; j < x.size(); ++j) mask |= (1 << (x[j] - '0'));
}
}

long long solve() {
long long ans = 0;
for(int m1 = 0; m1 <= 1023; ++m1)
for(int m2 = 0; m2 <= 1023; ++m2)
if((m1 | m2) == 1023)
ans += m1 == m2 ? 1LL * cnt[m1] * (cnt[m1] - 1) : 1LL * cnt[m1] * cnt[m2];
return ans / 2LL;
}

void out(long long x) {
cout << x << endl;
}

int main() {
out(solve());
return 0;
}
```