Find Champion I - Problem
Tournament Champion Detection

You're organizing a competitive tournament with n teams numbered from 0 to n-1. Each team has faced every other team in head-to-head matches, and you have the complete results stored in a 2D boolean matrix.

Given a 0-indexed 2D boolean matrix grid of size n × n, where:
grid[i][j] == 1 means team i is stronger than team j
grid[i][j] == 0 means team j is stronger than team i

A team becomes the champion if no other team is stronger than it. Your task is to find and return the champion team number.

Goal: Find the team that has never lost to any other team (i.e., no team is stronger than the champion).

Input & Output

example_1.py — Basic 3-team tournament
$ Input: grid = [[0,1,1],[0,0,1],[0,0,0]]
Output: 2
💡 Note: Team 2 is stronger than both teams 0 and 1 (grid[2][0]=0 and grid[2][1]=0 means no team defeats team 2). Team 2 defeats team 1 (grid[2][1]=0 but grid[1][2]=1), and team 1 defeats team 0. So team 2 is the champion.
example_2.py — 2-team tournament
$ Input: grid = [[0,1],[0,0]]
Output: 1
💡 Note: Team 1 is stronger than team 0 (grid[1][0]=0 means team 0 doesn't defeat team 1, and grid[0][1]=1 means team 0 loses to team 1). Team 1 is the champion since no one defeats it.
example_3.py — Single team
$ Input: grid = [[0]]
Output: 0
💡 Note: With only one team, team 0 is automatically the champion since there are no opponents to defeat it.

Constraints

  • n == grid.length
  • n == grid[i].length
  • 2 ≤ n ≤ 100
  • grid[i][j] is 0 or 1
  • For all i, grid[i][i] == 0
  • For all i, j where i != j, grid[i][j] != grid[j][i]
  • Guaranteed that there exists a unique champion

Visualization

Tap to expand
🏆 Tournament Champion DetectionMatch Results GridT0T1T2T0T1T2011001000🏆 Champion AnalysisTeam 0: Column has 1s → Defeated by othersTeam 1: Column has 1s → Defeated by othersTeam 2: Column has all 0s → CHAMPION! 🏆Key Insight:A champion's column contains no 1s(except diagonal which is always 0)This means no team defeats the champion!
Understanding the Visualization
1
Understand the Grid
Each cell [i][j] tells us if team i beats team j
2
Find Undefeated Team
Look for the team that no other team has beaten
3
Verify Champion
The champion should have a column with all 0s (except diagonal)
Key Takeaway
🎯 Key Insight: The champion team can be identified by finding the column in the grid that has no 1s from other teams, indicating that no other team has defeated the champion.
Asked in
Google 15 Amazon 12 Meta 8 Microsoft 6
28.0K Views
Medium Frequency
~8 min Avg. Time
890 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