FunctionRacerProblemsRace

First Repeated Word

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

Return the first word in words that has already appeared earlier in the list. If no word repeats, return the empty string "".

Words are compared exactly, so "Cat" and "cat" are different words.

Example 1

words ["a","b","c","b","a"]
returns "b"

b is the first word seen a second time.

Example 2

words ["x","y","z"]
returns ""

Every word is different.

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