---
title: "2225. Find Players With Zero or One Losses"
url: "https://laigary.com/interview/coding/2225-find-players-with-zero-or-one-losses"
type: "note"
section: "coding"
date: "2025-04-04"
updated: "2025-04-04"
tags: ["Hash Table"]
---

# 2225. Find Players With Zero or One Losses

[2225\. Find Players With Zero or One Losses](https://leetcode.com/problems/find-players-with-zero-or-one-losses/)

```python
class Solution:
    def findWinners(self, matches: List[List[int]]) -> List[List[int]]:
        
        records = defaultdict(lambda: defaultdict(int))
        for match in matches:
            winner, loser = match
            records[winner]['win'] += 1
            records[winner]['lost'] += 0
            records[loser]['win'] += 0
            records[loser]['lost'] += 1
        
        a = []
        b = []
        
        for player, record in records.items():
            if record['lost'] == 0:
                a.append(player)
            elif record['lost'] == 1:
                b.append(player)
        
        return [sorted(a), sorted(b)]
```
