aboutsummaryrefslogtreecommitdiffstats
path: root/2225
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-01-15 23:03:58 +0000
committerterminaldweller <devi@terminaldweller.com>2024-01-15 23:03:58 +0000
commitce9070919867c72c0dfc31fad7004045c3ef6c6d (patch)
tree19b52d22ab62db9a8d594afbc592fd5ed5e35cf1 /2225
parent1347 (diff)
downloadleetcode-ce9070919867c72c0dfc31fad7004045c3ef6c6d.tar.gz
leetcode-ce9070919867c72c0dfc31fad7004045c3ef6c6d.zip
2225
Diffstat (limited to '2225')
-rwxr-xr-x2225/main.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/2225/main.py b/2225/main.py
new file mode 100755
index 0000000..ff9e1de
--- /dev/null
+++ b/2225/main.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+import typing
+
+
+class Solution:
+ def findWinners(
+ self, matches: typing.List[typing.List[int]]
+ ) -> typing.List[typing.List[int]]:
+ record: typing.Dict[int, int] = {}
+ zeroes = []
+ ones = []
+
+ for match in matches:
+ if match[0] not in record:
+ record[match[0]] = 0
+
+ if match[1] not in record:
+ record[match[1]] = 1
+ else:
+ record[match[1]] += 1
+
+ for k, v in record.items():
+ if v == 0:
+ zeroes.append(k)
+ elif v == 1:
+ ones.append(k)
+
+ return [sorted(zeroes), sorted(ones)]
+
+
+def main():
+ solution = Solution()
+ print(
+ solution.findWinners(
+ [
+ [1, 3],
+ [2, 3],
+ [3, 6],
+ [5, 6],
+ [5, 7],
+ [4, 5],
+ [4, 8],
+ [4, 9],
+ [10, 4],
+ [10, 9],
+ ]
+ )
+ )
+
+
+if __name__ == "__main__":
+ main()