1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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()
|