Find Champion I
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 such 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.
Example 1
0 1 0 0
Input
grid = [[0,1],[0,0]]Output
0Since
grid[0][1] == 1, team 0 is stronger than team 1, so team 0 is the champion.Example 2
0 0 1 1 0 1 0 0 0
Input
grid = [[0,0,1],[1,0,1],[0,0,0]]Output
1Team 1 is stronger than both team 0 and team 2, so team 1 is the champion.
Constraints
n == grid.lengthn == grid[i].length2 <= n <= 100grid[i][j]is either0or1.- For all
i grid[i][i]is0. - For all
i, jthati != j,grid[i][j] != grid[j][i]. - The input is generated such that if team
ais stronger than teamband teambis stronger than teamc, then teamais stronger than teamc.