Find Words Containing Character
Return the indices of the words in words that contain the single character x, in increasing order. If no word contains it, return an empty list.
Example 1
words ["leet","code"]
x "e"
returns [0,1]
Both words contain e.
Example 2
words ["abc","bcd","aaaa","cbc"]
x "a"
returns [0,2]
Words 0 and 2.
Constraints
1 <= len(words) <= 50- Words have 1 to 50 lowercase letters
xis one lowercase letter
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Strings problems
- Join the Non-Empty PartsBeginner
- Longest Vowel RunBeginner
- Longest Word in a SentenceBeginner
- Maximum Nesting Depth of ParenthesesBeginner
- Mirror CipherBeginner
- One Segment of OnesBeginner
- Percentage of Letter in StringBeginner
- Prefix of Any Word in a SentenceBeginner