leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2225.cpp (644B)


0 class Solution {
1 public:
2 vector<vector<int>> findWinners(const vector<vector<int>> &matches) {
3 static int count[100001];
4 vector<vector<int>> res(2);
6 memset(count, 0xFF, sizeof(count));
7 for (const auto &match : matches) {
8 if (count[match[0]] == -1) count[match[0]] = 0;
9 if (count[match[1]] == -1) count[match[1]] = 0;
10 count[match[1]]++;
11 }
13 for (int player = 1; player <= 100000; player++) {
14 if (count[player] == 0) res[0].push_back(player);
15 if (count[player] == 1) res[1].push_back(player);
16 }
17 return res;
18 }
19 };