Rank the Top Two Competition Teams
Problem statement
Four aligned arrays describe each team. Team i earns 3 * wins[i] + draws[i] points and has difference scored[i] - conceded[i].
Rank teams by points descending, then difference descending, then index ascending. Return the indices of the top two teams.
Function
topTwoTeams(wins: int[], draws: int[], scored: int[], conceded: int[]) → int[]Examples
Example 1
wins = [3,2,1]draws = [0,2,5]scored = [5,5,5]conceded = [1,1,1]return = [0,1]The primary point totals determine the top two.
Example 2
wins = [2,2,1]draws = [0,0,3]scored = [10,7,9]conceded = [4,4,4]return = [0,2]Equal points are ordered by larger scored-minus-conceded difference.
Constraints
2 <= wins.length <= 100000- All four arrays have equal length and contain values from 0 through 100000.