Given a string text, return the first word that repeats when scanning from left to right. Comparison should be case-insensitive, and punctuation should be ignored. If no word repeats, return an empty string.
Constraints
1 <= len(text) <= 10^5
text contains letters, digits, spaces, and punctuation
Word matching is case-insensitive
Ignore leading, trailing, and repeated punctuation around words
Function Signature
deffirst_repeated_word(text):
Interviewer
Your question is First Repeated Word in Paragraph. Start with the requirements in the Question tab.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.