Problem · Array
Rank Teams by Votes
Learn this problemProblem statement
Each vote ranks the same teams from highest to lowest. Rank teams by the number of first-place votes; break ties using second-place votes, then later positions, and finally alphabetical order.
Function
rankTeams(votes: String[]) → StringExamples
Example 1
votes = ["ABC","ACB","ABC","ACB","ACB"]return = "ACB"Team A is always first; C has more second-place votes than B.
Constraints
1 <= votes.length <= 1000- Each vote contains the same distinct uppercase teams.
- There are at most
26teams.