First Repeated Word
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
0 <= len(words) <= 1001 <= len(words[i]) <= 10words[i]has lowercase or uppercase letters only
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Hash maps problems
- Is IsogramBeginner
- Jewels and StonesBeginner
- Keep First of Each LetterBeginner
- Letter Count TableBeginner
- Matching Sock PairsBeginner
- Translate With a GlossaryBeginner
- Unfilled OrdersBeginner
- Check If N and Its Double ExistEasy