Find Top Two Teams
Problem statement
The arrays wins, draws, scored, and conceded describe the statistics of n teams. Team i earns 3 * wins[i] + draws[i] league points.
Return the indices of the highest-ranked and second-highest-ranked teams in that order. Rank teams by league points descending, then by goal difference scored[i] - conceded[i] descending. If both values are equal, the smaller team index ranks first.
Function
findTopTwoTeams(wins: int[], draws: int[], scored: int[], conceded: int[]) → int[]Examples
Example 1
wins = [1, 2, 3]draws = [1, 1, 1]scored = [10, 20, 30]conceded = [12, 23, 12]return = [2, 1]The teams earn 4, 7, and 10 league points. Team 2 ranks first and team 1 ranks second, so the result is [2, 1].
Constraints
2 <= n <= 100000.wins.length == draws.length == scored.length == conceded.length == n.0 <= wins[i], draws[i], scored[i], conceded[i] <= 10^9.