aboutsummaryrefslogtreecommitdiff
path: root/other/find_player_zero_one_loss.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'other/find_player_zero_one_loss.cpp')
-rw-r--r--other/find_player_zero_one_loss.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/other/find_player_zero_one_loss.cpp b/other/find_player_zero_one_loss.cpp
new file mode 100644
index 0000000..5aba77e
--- /dev/null
+++ b/other/find_player_zero_one_loss.cpp
@@ -0,0 +1,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};
+ }
+};