From ce9070919867c72c0dfc31fad7004045c3ef6c6d Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Mon, 15 Jan 2024 18:03:58 -0500 Subject: 2225 --- 2225/main.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 2225/main.py (limited to '2225/main.py') 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() -- cgit v1.2.3