There are n teams labeled 0 through n - 1. The directed edge [u, v] means that team u is stronger than team v. The given directed graph has no cycles. Strength is transitive: if one team is stronger than a second, which is stronger than a third, then the first is also stronger than the third.
A champion is a team with no stronger team. Return its label if exactly one champion exists; otherwise return -1.
Edges describe strength relationships, and a sequence of edges also establishes which teams are stronger. Isolated teams are allowed.
Example 1:
Input: n = 4
edges = [[2,0],[0,1],[2,3]]
Output: 2Explanation: Team 2 is stronger than teams 0 and 3 directly, and stronger than team 1 through team 0. No team is stronger than team 2, making it the unique champion.
Example 2:
Input: n = 3
edges = [[0,2],[1,2]]
Output: -1Explanation: Teams 0 and 1 are both stronger than team 2, but neither has a stronger team. There are two candidates, so no unique champion exists.
Example 3:
Input: n = 1
edges = []
Output: 0Explanation: With just one team and no edges, team 0 has no stronger opponent and is the unique champion.
Constraints:
1 <= n <= 1000 <= edges.length <= n * (n - 1) / 2edges[i].length == 2- Edge endpoints are distinct team labels between
0andn - 1. - Edges are distinct, and the directed graph has no cycles.