2923. Find Champion I Easy
1/**
2 * [2923] Find Champion I
3 *
4 * There are n teams numbered from 0 to n - 1 in a tournament.
5 * 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.
6 * Team a will be the champion of the tournament if there is no team b that is stronger than team a.
7 * Return the team that will be the champion of the tournament.
8 *
9 * <strong class="example">Example 1:
10 *
11 * Input: grid = [[0,1],[0,0]]
12 * Output: 0
13 * Explanation: There are two teams in this tournament.
14 * grid[0][1] == 1 means that team 0 is stronger than team 1. So team 0 will be the champion.
15 *
16 * <strong class="example">Example 2:
17 *
18 * Input: grid = [[0,0,1],[1,0,1],[0,0,0]]
19 * Output: 1
20 * Explanation: There are three teams in this tournament.
21 * grid[1][0] == 1 means that team 1 is stronger than team 0.
22 * grid[1][2] == 1 means that team 1 is stronger than team 2.
23 * So team 1 will be the champion.
24 *
25 *
26 * Constraints:
27 *
28 * n == grid.length
29 * n == grid[i].length
30 * 2 <= n <= 100
31 * grid[i][j] is either 0 or 1.
32 * For all i grid[i][i] is 0.
33 * For all i, j that i != j, grid[i][j] != grid[j][i].
34 * The input is generated such that if team a is stronger than team b and team b is stronger than team c, then team a is stronger than team c.
35 *
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/find-champion-i/
40// discuss: https://leetcode.com/problems/find-champion-i/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45 pub fn find_champion(grid: Vec<Vec<i32>>) -> i32 {
46 0
47 }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_2923() {
58 }
59}
60
Back
© 2025 bowen.ge All Rights Reserved.