Skip to content

Commit bdf4762

Browse files
committed
docs: update README.md
1 parent 6227b40 commit bdf4762

File tree

1 file changed

+28
-0
lines changed
  • solution/2200-2299/2225.Find Players With Zero or One Losses

1 file changed

+28
-0
lines changed

solution/2200-2299/2225.Find Players With Zero or One Losses/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,34 @@ func findWinners(matches [][]int) [][]int {
167167
}
168168
```
169169

170+
### **JavaScript**
171+
172+
```js
173+
var findWinners = function (matches) {
174+
const onlyWins = new Set(),
175+
oneLose = new Set(),
176+
moreLosses = new Set();
177+
178+
for (const [winner, loser] of matches) {
179+
if (!moreLosses.has(loser)) {
180+
if (oneLose.has(loser)) {
181+
oneLose.delete(loser);
182+
moreLosses.add(loser);
183+
} else {
184+
onlyWins.delete(loser);
185+
oneLose.add(loser);
186+
}
187+
}
188+
189+
if (!moreLosses.has(winner) && !oneLose.has(winner)) {
190+
onlyWins.add(winner);
191+
}
192+
}
193+
194+
return [[...onlyWins].sort((a, b) => a - b), [...oneLose].sort((a, b) => a - b)];
195+
};
196+
```
197+
170198
### **TypeScript**
171199

172200
```ts

0 commit comments

Comments
 (0)