There are n teams numbered from 0 to n - 1 in a tournament; each team is also a node in a <strong>DAG</strong>.You are given the integer n and a <strong>0-indexed</strong> 2D integer array edges of length m representing the <strong>DAG</strong>, where edges[i] = [u_i, v_i] indicates that there is a directed edge from team u_i to team v_i in the graph.A directed edge from a to b in the graph means that team a is <strong>stronger</strong> than team b and team b is <strong>weaker</strong> than team a.Team a will be the <strong>champion</strong> of the tournament if there is no team b that is <strong>stronger</strong> than team a.Return <em>the team that will be the <strong>champion</strong> of the tournament if there is a <strong>unique</strong> champion, otherwise, return </em><code>-1</code><em>.</em>
Input: n = 3, edges = [[0,1],[1,2]]Output: 0Explanation: Team 1 is weaker than team 0. Team 2 is weaker than team 1. So the champion is team 0.
Input: n = 4, edges = [[0,2],[1,3],[1,2]]Output: -1Explanation: Team 2 is weaker than team 0 and team 1. Team 3 is weaker than team 1. But team 1 and team 0 are not weaker than any other teams. So the answer is -1.
class Solution: # Time: O(n + m) # Space: O(n) def find_champion(self, n: int, edges: list[list[int]]) -> int: weaker_count = [0] * n for _stronger, weaker in edges: weaker_count[weaker] += 1 champions = [team for team in range(n) if weaker_count[team] == 0] return champions[0] if len(champions) == 1 else -1