|
4 | 4 |
|
5 | 5 | ## Description
|
6 | 6 |
|
7 |
| -<p>Alice and Bob have an undirected graph of <code>n</code> nodes and 3 types of edges:</p> |
| 7 | +<p>Alice and Bob have an undirected graph of <code>n</code> nodes and three types of edges:</p> |
8 | 8 |
|
9 | 9 | <ul>
|
10 | 10 | <li>Type 1: Can be traversed by Alice only.</li>
|
11 | 11 | <li>Type 2: Can be traversed by Bob only.</li>
|
12 |
| - <li>Type 3: Can by traversed by both Alice and Bob.</li> |
| 12 | + <li>Type 3: Can be traversed by both Alice and Bob.</li> |
13 | 13 | </ul>
|
14 | 14 |
|
15 |
| -<p>Given an array <code>edges</code> where <code>edges[i] = [type<sub>i</sub>, u<sub>i</sub>, v<sub>i</sub>]</code> represents a bidirectional edge of type <code>type<sub>i</sub></code> between nodes <code>u<sub>i</sub></code> and <code>v<sub>i</sub></code>, find the maximum number of edges you can remove so that after removing the edges, the graph can still be fully traversed by both Alice and Bob. The graph is fully traversed by Alice and Bob if starting from any node, they can reach all other nodes.</p> |
| 15 | +<p>Given an array <code>edges</code> where <code>edges[i] = [type<sub>i</sub>, u<sub>i</sub>, v<sub>i</sub>]</code> represents a bidirectional edge of type <code>type<sub>i</sub></code> between nodes <code>u<sub>i</sub></code> and <code>v<sub>i</sub></code>, find the maximum number of edges you can remove so that after removing the edges, the graph can still be fully traversed by both Alice and Bob. The graph is fully traversed by Alice and Bob if starting from any node, they can reach all other nodes.</p> |
16 | 16 |
|
17 |
| -<p>Return <em>the maximum number of edges you can remove, or return</em> <code>-1</code> <em>if it's impossible for the graph to be fully traversed by Alice and Bob.</em></p> |
| 17 | +<p>Return <em>the maximum number of edges you can remove, or return</em> <code>-1</code> <em>if Alice and Bob cannot fully traverse the graph.</em></p> |
18 | 18 |
|
19 | 19 | <p> </p>
|
20 | 20 | <p><strong>Example 1:</strong></p>
|
|
52 | 52 | <p><strong>Constraints:</strong></p>
|
53 | 53 |
|
54 | 54 | <ul>
|
55 |
| - <li><code>1 <= n <= 10^5</code></li> |
56 |
| - <li><code>1 <= edges.length <= min(10^5, 3 * n * (n-1) / 2)</code></li> |
| 55 | + <li><code>1 <= n <= 10<sup>5</sup></code></li> |
| 56 | + <li><code>1 <= edges.length <= min(10<sup>5</sup>, 3 * n * (n - 1) / 2)</code></li> |
57 | 57 | <li><code>edges[i].length == 3</code></li>
|
58 |
| - <li><code>1 <= edges[i][0] <= 3</code></li> |
59 |
| - <li><code>1 <= edges[i][1] < edges[i][2] <= n</code></li> |
60 |
| - <li>All tuples <code>(type<sub>i</sub>, u<sub>i</sub>, v<sub>i</sub>)</code> are distinct.</li> |
| 58 | + <li><code>1 <= type<sub>i</sub> <= 3</code></li> |
| 59 | + <li><code>1 <= u<sub>i</sub> < v<sub>i</sub> <= n</code></li> |
| 60 | + <li>All tuples <code>(type<sub>i</sub>, u<sub>i</sub>, v<sub>i</sub>)</code> are distinct.</li> |
61 | 61 | </ul>
|
62 | 62 |
|
63 | 63 | ## Solutions
|
|
0 commit comments