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
Find Champion I: Tournament MatrixInput: Tournament Grid011101000012012Analysis:Team 0: beats team 1 and 2Team 1: beats team 0 and 2Team 2: beats nobodyDefeats Count:Team 0: 0 defeats ✓Team 1: 1 defeatTeam 2: 2 defeatsChampion: Team 0
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
Asked in
Google 35 Amazon 28 Meta 22 Microsoft 18
25.4K Views
Medium Frequency
~15 min Avg. Time
892 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen