aboutsummaryrefslogtreecommitdiff
path: root/find_player_zero_one_loss.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'find_player_zero_one_loss.cpp')
-rw-r--r--find_player_zero_one_loss.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/find_player_zero_one_loss.cpp b/find_player_zero_one_loss.cpp
new file mode 100644
index 0000000..75c0e15
--- /dev/null
+++ b/find_player_zero_one_loss.cpp
@@ -0,0 +1,21 @@
+#include "leetcode.h"
+
+class Solution {
+public:
+ vvd(int) findWinners(vvd(int) & 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};
+ }
+};