Best Score per Name
names and scores have the same length: in round i the player names[i] scored scores[i]. A player may play several rounds.
Return a dictionary that maps every player to the highest score they got in any round. Empty lists give an empty dictionary.
Example 1
names ["ann","bob","ann"]
scores [10,7,4]
returns {"ann":10,"bob":7}
ann scored 10 and 4, so her best is 10; bob only scored 7.
Example 2
names ["bob","bob"]
scores [3,9]
returns {"bob":9}
bob improved from 3 to 9.
Constraints
0 <= len(names) <= 100andlen(scores) == len(names)-1000 <= scores[i] <= 1000- names are 1 to 8 lowercase letters
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Hash maps problems
- Check if the Sentence Is PangramBeginner
- Count Elements With a NextBeginner
- Difference of Two ArraysBeginner
- First Repeated WordBeginner
- Is IsogramBeginner
- Jewels and StonesBeginner
- Keep First of Each LetterBeginner
- Letter Count TableBeginner