FunctionRacerProblemsRace

Best Score per Name

BeginnerHash mapsPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Hash maps problems