aboutsummaryrefslogtreecommitdiff
path: root/find_player_zero_one_loss.cpp
blob: 5aba77e03b5e618e161e836f6de37d95999a21c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "leetcode.h"

class Solution {
public:
  vvd findWinners(vvd & matches) {
    map<int, int> lost;
    for (auto m : matches) {
      if (!lost.count(m[0]))
        lost[m[0]] = 0;
      lost[m[1]]++;
    }
    vector<int> zero, ones;
    for (auto [k, l] : lost) {
      if (l == 0)
        zero.push_back(k);
      if (l == 1)
        ones.push_back(k);
    }
    return {zero, ones};
  }
};