946. Find the Word with Highest Number of Repeated Letters in a String
Given a string s containing multiple words, find and return the word that has the highest number of repeated letters.
- If multiple words have the same highest number of repeated letters, return the first such word.
- If no word contains any repeated letters, return -1.
Example 1:
Input: "abcdefghij google microsoft"
Output: "google"
Explanation:
- "google": g:2, o:2
- "microsoft": no letter repeated
- So, "google" has the highest repeat count (2)
Example 2:
Input: "cameron blue"
Output: -1
Explanation: No letter is repeated in any word
Now Your Turn!
Pick the correct output for the given inputInput: "abc def ghi"
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.