2225. Find Players With Zero or One Losses

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2225

class Solution:
    def findWinners(self, matches: List[List[int]]) -> List[List[int]]:
        cnt = Counter()
        for a, b in matches:
            if a not in cnt:
                cnt[a] = 0
            cnt[b] += 1
        res = [[], []]
        for u, v in cnt.items():
            if v < 2:
                res[v].append(u)
        res[0].sort()
        res[1].sort()
        return res