You get scores, a mutable.Map from players' names to their scores. Return the name of the player with the highest score.
Several players may share the highest score. Then return the name that comes first in alphabetical order.
Example 1:
Input: scores = {"Ana": 90, "Ben": 75, "Cara": 88}
Output: "Ana"
Explanation: 90 is the highest score, and it is Ana's.
Example 2:
Input: scores = {"Zoe": 82, "Ana": 82}
Output: "Ana"
Explanation: Both have 82. "Ana" comes before "Zoe" in alphabetical order.
Example 3:
Input: scores = {"Max": 0}
Output: "Max"
Explanation: Max is the only player, so his score is the highest.
Constraints:
scoreshas at least one name.- Every score is a whole number from 0 to 100.
- Each name is a capital letter followed by lowercase letters, like
"Ana".
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
