ballots.
The final standings work like this: whoever was placed first on more ballots ranks higher. If that is a tie, compare how many second places they got, then third places, and so on. If two finalists have equal counts for every place, the one whose letter comes earlier in the alphabet ranks higher.
Return a string with the letters of all finalists in the order of the final standings.ballots=["PQR", "QPR", "PRQ"] → 'PQR'
P is first on two ballots, Q on one and R on none, so first places alone already give the order P, Q, R.
ballots=["MN", "NM"] → 'MN'
M and N tie on every place, so the alphabet decides: M comes first.
ballots=["KDA"] → 'KDA'
ballots=["PQR", "QPR", "PRQ"]
'PQR'
Run checks the first 3 tests in your browser. Submit checks all 61 tests on the server, hidden ones included.