You get a list of players, players. Each player is a pair: a name and a score, like ("Ava", 30).
Return the names, from the highest score to the lowest.
Players with the same score go in alphabetical order of their names.
The starter code shows how your language holds a pair.
Example 1:
Input: players = [("Ava", 30), ("Ben", 25), ("Cy", 40)]
Output: ["Cy", "Ava", "Ben"]
Explanation: Cy has the most points, 40.
Then come Ava with 30 and Ben with 25.
Example 2:
Input: players = [("Mia", 50), ("Leo", 70), ("Ava", 50)]
Output: ["Leo", "Ava", "Mia"]
Explanation: Leo leads with 70.
Ava and Mia both have 50.
Ava comes first from A to Z.
Example 3:
Input: players = [("Zoe", 0)]
Output: ["Zoe"]
Explanation: Zoe is the only player.
Constraints:
playershas 1 to 100 players.- Every score is a whole number from 0 to 1000.
- Each name is a capital letter followed by lowercase letters, like
"Ava". - No two players have the same name.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
