Problem · Array

Rank Teams by Votes

Learn this problem
MediumAtlassian logoAtlassianFULLTIMEOA

Problem 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[]) → String

Examples

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 26 teams.

More Atlassian problems

drafts saved locally
public String rankTeams(String[] votes) {
  // Write your code here.
}
votes["ABC","ACB","ABC","ACB","ACB"]
expected"ACB"
checking account