teams teams numbered from 0 to teams - 1. Each record wins[i] = [a, b] means team a is stronger than team b. Strength carries along chains: if a is stronger than b and b is stronger than c, then a is stronger than c. The records never contradict each other, so no team can end up stronger than itself through a chain.
A team is a leader if no team is stronger than it. If there is exactly one leader, return its number; otherwise return -1.teams=4, wins=[[2, 0], [0, 3], [2, 1]] → 2
Nobody has beaten team 2, while every other team has lost to someone. So team 2 is the leader.
teams=3, wins=[[0, 2]] → -1
Neither team 0 nor team 1 has lost, and they never played each other, so there is no single leader.
teams=1, wins=[] → 0
wins at most onceteams=4, wins=[[2, 0], [0, 3], [2, 1]]
2
Run checks the first 3 tests in your browser. Submit checks all 66 tests on the server, hidden ones included.