Find Champion I - Problem
There are n teams numbered from 0 to n - 1 in a tournament.
Given a 0-indexed 2D boolean matrix grid of size n * n. For all i, j that 0 <= i, j <= n - 1 and i != j, team i is stronger than team j if grid[i][j] == 1, otherwise, team j is stronger than team i.
Team a will be the champion of the tournament if there is no team b that is stronger than team a.
Return the team that will be the champion of the tournament.
Input & Output
Example 1 — Basic 3x3 Tournament
$
Input:
grid = [[0,1,1],[1,0,1],[0,0,0]]
›
Output:
0
💡 Note:
Team 0 beats teams 1 and 2 (grid[0][1]=1, grid[0][2]=1). Team 1 beats team 2 (grid[1][2]=1). No team beats team 0, so team 0 is the champion.
Example 2 — Different Champion
$
Input:
grid = [[0,0,1],[1,0,1],[0,0,0]]
›
Output:
1
💡 Note:
Team 1 beats teams 0 and 2. Team 0 beats team 2. No team beats team 1, so team 1 is the champion.
Example 3 — Small Tournament
$
Input:
grid = [[0,1],[0,0]]
›
Output:
0
💡 Note:
Team 0 beats team 1 (grid[0][1]=1). No team beats team 0, making team 0 the champion.
Constraints
- n == grid.length
- n == grid[i].length
- 2 ≤ n ≤ 100
- grid[i][j] is either 0 or 1
- For all i grid[i][i] = 0
Visualization
Tap to expand
Understanding the Visualization
1
Input
Tournament grid where grid[i][j]=1 means team i beats team j
2
Process
Find team with no defeats (no incoming wins from others)
3
Output
Return the champion team number
Key Takeaway
🎯 Key Insight: The champion is the team that no other team defeats
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code