Tap here to switch tabs
Problem
Submissions

Problem: Find Champion II

Try to solve the Find Champion II problem.

Statement

There are n teams numbered from 00 to n −1- 1 participating in a tournament.

You are given a 2D2 {D} integer array edges of length m, where each edges[i] = [u, v] represents a directed edge indicating that team u is stronger than team v. A team a is considered a champion if there is no team b that is stronger than team a.

Return the team that is the champion if there is a unique champion. If there is no unique champion, return −1-1.

Constraints:

  • 1≤1 \leq n ≤100\leq 100

  • m ==== edges.length

  • 0≤0 \leq m ≤\leq n ×\times ( n −1)/2- 1) / 2

  • edges[i].length ==2== 2

  • 0≤0 \leq edges[i][j] ≤\leq n −1- 1

  • edges[i][0] ≠\neq edges[i][1]

  • The input is generated such that if team a is stronger than team b, team b is not stronger than team a.

  • 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.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Champion II

Try to solve the Find Champion II problem.

Statement

There are n teams numbered from 00 to n −1- 1 participating in a tournament.

You are given a 2D2 {D} integer array edges of length m, where each edges[i] = [u, v] represents a directed edge indicating that team u is stronger than team v. A team a is considered a champion if there is no team b that is stronger than team a.

Return the team that is the champion if there is a unique champion. If there is no unique champion, return −1-1.

Constraints:

  • 1≤1 \leq n ≤100\leq 100

  • m ==== edges.length

  • 0≤0 \leq m ≤\leq n ×\times ( n −1)/2- 1) / 2

  • edges[i].length ==2== 2

  • 0≤0 \leq edges[i][j] ≤\leq n −1- 1

  • edges[i][0] ≠\neq edges[i][1]

  • The input is generated such that if team a is stronger than team b, team b is not stronger than team a.

  • 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.