Skip to main content
Back to problems
#2923
Easy Algorithms

Find champion i

Array Matrix
73.3% acceptance
Feb 25, 2026
187
54
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.

Solution

Rust
Time O(n)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn find_champion(grid: Vec<Vec<i32>>) -> i32 {
    let n = grid.len();
    for i in 0..n {
      if grid[i].iter().map(|&x| x as usize).sum::<usize>() == n - 1 {
        return i as i32;
      }
    }
    -1
  }
}