Skip to content

Commit 0e4fe50

Browse files
committed
Create README - LeetHub
1 parent 0a190f8 commit 0e4fe50

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

2924-find-champion-ii/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<h2><a href="https://leetcode.com/problems/find-champion-ii/">2924. Find Champion II</a></h2><h3>Medium</h3><hr><div><p>There are <code>n</code> teams numbered from <code>0</code> to <code>n - 1</code> in a tournament; each team is also a node in a <strong>DAG</strong>.</p>
2+
3+
<p>You are given the integer <code>n</code> and a <strong>0-indexed</strong> 2D integer array <code>edges</code> of length <code><font face="monospace">m</font></code> representing the <strong>DAG</strong>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>]</code> indicates that there is a directed edge from team <code>u<sub>i</sub></code> to team <code>v<sub>i</sub></code> in the graph.</p>
4+
5+
<p>A directed edge from <code>a</code> to <code>b</code> in the graph means that team <code>a</code> is <strong>stronger</strong> than team <code>b</code> and team <code>b</code> is <strong>weaker</strong> than team <code>a</code>.</p>
6+
7+
<p>Team <code>a</code> will be the <strong>champion</strong> of the tournament if there is no team <code>b</code> that is <strong>stronger</strong> than team <code>a</code>.</p>
8+
9+
<p>Return <em>the team that will be the <strong>champion</strong> of the tournament if there is a <strong>unique</strong> champion, otherwise, return </em><code>-1</code><em>.</em></p>
10+
11+
<p><strong>Notes</strong></p>
12+
13+
<ul>
14+
<li>A <strong>cycle</strong> is a series of nodes <code>a<sub>1</sub>, a<sub>2</sub>, ..., a<sub>n</sub>, a<sub>n+1</sub></code> such that node <code>a<sub>1</sub></code> is the same node as node <code>a<sub>n+1</sub></code>, the nodes <code>a<sub>1</sub>, a<sub>2</sub>, ..., a<sub>n</sub></code> are distinct, and there is a directed edge from the node <code>a<sub>i</sub></code> to node <code>a<sub>i+1</sub></code> for every <code>i</code> in the range <code>[1, n]</code>.</li>
15+
<li>A <strong>DAG</strong> is a directed graph that does not have any <strong>cycle</strong>.</li>
16+
</ul>
17+
18+
<p>&nbsp;</p>
19+
<p><strong class="example">Example 1:</strong></p>
20+
21+
<p><img height="300" src="https://assets.leetcode.com/uploads/2023/10/19/graph-3.png" width="300"></p>
22+
23+
<pre><strong>Input:</strong> n = 3, edges = [[0,1],[1,2]]
24+
<strong>Output:</strong> 0
25+
<strong>Explanation: </strong>Team 1 is weaker than team 0. Team 2 is weaker than team 1. So the champion is team 0.
26+
</pre>
27+
28+
<p><strong class="example">Example 2:</strong></p>
29+
30+
<p><img height="300" src="https://assets.leetcode.com/uploads/2023/10/19/graph-4.png" width="300"></p>
31+
32+
<pre><strong>Input:</strong> n = 4, edges = [[0,2],[1,3],[1,2]]
33+
<strong>Output:</strong> -1
34+
<strong>Explanation:</strong> Team 2 is weaker than team 0 and team 1. Team 3 is weaker than team 1. But team 1 and team 0 are not weaker than any other teams. So the answer is -1.
35+
</pre>
36+
37+
<p>&nbsp;</p>
38+
<p><strong>Constraints:</strong></p>
39+
40+
<ul>
41+
<li><code>1 &lt;= n &lt;= 100</code></li>
42+
<li><code>m == edges.length</code></li>
43+
<li><code>0 &lt;= m &lt;= n * (n - 1) / 2</code></li>
44+
<li><code>edges[i].length == 2</code></li>
45+
<li><code>0 &lt;= edge[i][j] &lt;= n - 1</code></li>
46+
<li><code>edges[i][0] != edges[i][1]</code></li>
47+
<li>The input is generated such that if team <code>a</code> is stronger than team <code>b</code>, team <code>b</code> is not stronger than team <code>a</code>.</li>
48+
<li>The input is generated such that if team <code>a</code> is stronger than team <code>b</code> and team <code>b</code> is stronger than team <code>c</code>, then team <code>a</code> is stronger than team <code>c</code>.</li>
49+
</ul>
50+
</div>

0 commit comments

Comments
 (0)