|
26 | 26 | <p>If the town judge exists and can be identified, return the label of the town judge. Otherwise, return <code>-1</code>.</p>
|
27 | 27 |
|
28 | 28 | <p> </p>
|
29 |
| - |
30 | 29 | <p><strong>Example 1:</strong></p>
|
31 |
| - |
32 |
| -<pre> |
33 |
| -<strong>Input: </strong>N = <span id="example-input-1-1">2</span>, trust = <span id="example-input-1-2">[[1,2]]</span> |
34 |
| -<strong>Output: </strong><span id="example-output-1">2</span> |
35 |
| -</pre> |
36 |
| - |
37 |
| -<div> |
38 |
| -<p><strong>Example 2:</strong></p> |
39 |
| - |
40 |
| -<pre> |
41 |
| -<strong>Input: </strong>N = <span id="example-input-2-1">3</span>, trust = <span id="example-input-2-2">[[1,3],[2,3]]</span> |
42 |
| -<strong>Output: </strong><span id="example-output-2">3</span> |
| 30 | +<pre><strong>Input:</strong> N = 2, trust = [[1,2]] |
| 31 | +<strong>Output:</strong> 2 |
| 32 | +</pre><p><strong>Example 2:</strong></p> |
| 33 | +<pre><strong>Input:</strong> N = 3, trust = [[1,3],[2,3]] |
| 34 | +<strong>Output:</strong> 3 |
| 35 | +</pre><p><strong>Example 3:</strong></p> |
| 36 | +<pre><strong>Input:</strong> N = 3, trust = [[1,3],[2,3],[3,1]] |
| 37 | +<strong>Output:</strong> -1 |
| 38 | +</pre><p><strong>Example 4:</strong></p> |
| 39 | +<pre><strong>Input:</strong> N = 3, trust = [[1,2],[2,3]] |
| 40 | +<strong>Output:</strong> -1 |
| 41 | +</pre><p><strong>Example 5:</strong></p> |
| 42 | +<pre><strong>Input:</strong> N = 4, trust = [[1,3],[1,4],[2,3],[2,4],[4,3]] |
| 43 | +<strong>Output:</strong> 3 |
43 | 44 | </pre>
|
44 |
| - |
45 |
| -<div> |
46 |
| -<p><strong>Example 3:</strong></p> |
47 |
| - |
48 |
| -<pre> |
49 |
| -<strong>Input: </strong>N = <span id="example-input-3-1">3</span>, trust = <span id="example-input-3-2">[[1,3],[2,3],[3,1]]</span> |
50 |
| -<strong>Output: </strong><span id="example-output-3">-1</span> |
51 |
| -</pre> |
52 |
| - |
53 |
| -<div> |
54 |
| -<p><strong>Example 4:</strong></p> |
55 |
| - |
56 |
| -<pre> |
57 |
| -<strong>Input: </strong>N = <span id="example-input-4-1">3</span>, trust = <span id="example-input-4-2">[[1,2],[2,3]]</span> |
58 |
| -<strong>Output: </strong><span id="example-output-4">-1</span> |
59 |
| -</pre> |
60 |
| - |
61 |
| -<div> |
62 |
| -<p><strong>Example 5:</strong></p> |
63 |
| - |
64 |
| -<pre> |
65 |
| -<strong>Input: </strong>N = <span id="example-input-5-1">4</span>, trust = <span id="example-input-5-2">[[1,3],[1,4],[2,3],[2,4],[4,3]]</span> |
66 |
| -<strong>Output: </strong><span id="example-output-5">3</span></pre> |
67 |
| - |
68 | 45 | <p> </p>
|
69 |
| -</div> |
70 |
| -</div> |
71 |
| -</div> |
72 |
| -</div> |
73 |
| - |
74 |
| -<p><strong>Note:</strong></p> |
| 46 | +<p><strong>Constraints:</strong></p> |
75 | 47 |
|
76 |
| -<ol> |
| 48 | +<ul> |
77 | 49 | <li><code>1 <= N <= 1000</code></li>
|
78 |
| - <li><code>trust.length <= 10000</code></li> |
| 50 | + <li><code>0 <= trust.length <= 10^4</code></li> |
| 51 | + <li><code>trust[i].length == 2</code></li> |
79 | 52 | <li><code>trust[i]</code> are all different</li>
|
80 | 53 | <li><code>trust[i][0] != trust[i][1]</code></li>
|
81 | 54 | <li><code>1 <= trust[i][0], trust[i][1] <= N</code></li>
|
82 |
| -</ol> |
| 55 | +</ul> |
83 | 56 |
|
84 | 57 | ### Related Topics
|
85 | 58 | [[Graph](../../tag/graph/README.md)]
|
|
0 commit comments