|
| 1 | +<h2><a href="https://leetcode.com/problems/find-players-with-zero-or-one-losses/">2225. Find Players With Zero or One Losses</a></h2><h3>Medium</h3><hr><div><p>You are given an integer array <code>matches</code> where <code>matches[i] = [winner<sub>i</sub>, loser<sub>i</sub>]</code> indicates that the player <code>winner<sub>i</sub></code> defeated player <code>loser<sub>i</sub></code> in a match.</p> |
| 2 | + |
| 3 | +<p>Return <em>a list </em><code>answer</code><em> of size </em><code>2</code><em> where:</em></p> |
| 4 | + |
| 5 | +<ul> |
| 6 | + <li><code>answer[0]</code> is a list of all players that have <strong>not</strong> lost any matches.</li> |
| 7 | + <li><code>answer[1]</code> is a list of all players that have lost exactly <strong>one</strong> match.</li> |
| 8 | +</ul> |
| 9 | + |
| 10 | +<p>The values in the two lists should be returned in <strong>increasing</strong> order.</p> |
| 11 | + |
| 12 | +<p><strong>Note:</strong></p> |
| 13 | + |
| 14 | +<ul> |
| 15 | + <li>You should only consider the players that have played <strong>at least one</strong> match.</li> |
| 16 | + <li>The testcases will be generated such that <strong>no</strong> two matches will have the <strong>same</strong> outcome.</li> |
| 17 | +</ul> |
| 18 | + |
| 19 | +<p> </p> |
| 20 | +<p><strong class="example">Example 1:</strong></p> |
| 21 | + |
| 22 | +<pre><strong>Input:</strong> matches = [[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[4,9],[10,4],[10,9]] |
| 23 | +<strong>Output:</strong> [[1,2,10],[4,5,7,8]] |
| 24 | +<strong>Explanation:</strong> |
| 25 | +Players 1, 2, and 10 have not lost any matches. |
| 26 | +Players 4, 5, 7, and 8 each have lost one match. |
| 27 | +Players 3, 6, and 9 each have lost two matches. |
| 28 | +Thus, answer[0] = [1,2,10] and answer[1] = [4,5,7,8]. |
| 29 | +</pre> |
| 30 | + |
| 31 | +<p><strong class="example">Example 2:</strong></p> |
| 32 | + |
| 33 | +<pre><strong>Input:</strong> matches = [[2,3],[1,3],[5,4],[6,4]] |
| 34 | +<strong>Output:</strong> [[1,2,5,6],[]] |
| 35 | +<strong>Explanation:</strong> |
| 36 | +Players 1, 2, 5, and 6 have not lost any matches. |
| 37 | +Players 3 and 4 each have lost two matches. |
| 38 | +Thus, answer[0] = [1,2,5,6] and answer[1] = []. |
| 39 | +</pre> |
| 40 | + |
| 41 | +<p> </p> |
| 42 | +<p><strong>Constraints:</strong></p> |
| 43 | + |
| 44 | +<ul> |
| 45 | + <li><code>1 <= matches.length <= 10<sup>5</sup></code></li> |
| 46 | + <li><code>matches[i].length == 2</code></li> |
| 47 | + <li><code>1 <= winner<sub>i</sub>, loser<sub>i</sub> <= 10<sup>5</sup></code></li> |
| 48 | + <li><code>winner<sub>i</sub> != loser<sub>i</sub></code></li> |
| 49 | + <li>All <code>matches[i]</code> are <strong>unique</strong>.</li> |
| 50 | +</ul> |
| 51 | +</div> |
0 commit comments