Class Solution
java.lang.Object
g2901_3000.s2942_find_words_containing_character.Solution
public class Solution
extends java.lang.Object
2942 - Find Words Containing Character.
Easy
You are given a 0-indexed array of strings words
and a character x
.
Return an array of indices representing the words that contain the character x
.
Note that the returned array may be in any order.
Example 1:
Input: words = [“leet”,“code”], x = “e”
Output: [0,1]
Explanation: “e” occurs in both words: “l**ee**t”, and “cod e ”. Hence, we return indices 0 and 1.
Example 2:
Input: words = [“abc”,“bcd”,“aaaa”,“cbc”], x = “a”
Output: [0,2]
Explanation: “a” occurs in “**a**bc”, and “ aaaa ”. Hence, we return indices 0 and 2.
Example 3:
Input: words = [“abc”,“bcd”,“aaaa”,“cbc”], x = “z”
Output: []
Explanation: “z” does not occur in any of the words. Hence, we return an empty array.
Constraints:
1 <= words.length <= 50
1 <= words[i].length <= 50
x
is a lowercase English letter.words[i]
consists only of lowercase English letters.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionjava.util.List
<java.lang.Integer> findWordsContaining
(java.lang.String[] words, char x) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
findWordsContaining
public java.util.List<java.lang.Integer> findWordsContaining(java.lang.String[] words, char x)
-