Find Words Containing Character

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
Inputwords = ["leet","code"], x = "e"
Output[0,1]
"e" occurs in both words, so indices 0 and 1 are returned.
Example 2
Inputwords = ["abc","bcd","aaaa","cbc"], x = "a"
Output[0,2]
"a" occurs in "abc" and "aaaa", so indices 0 and 2 are returned.

Constraints

  • 1 <= words.length <= 50
  • 1 <= words[i].length <= 50
  • x is a lowercase English letter.
  • words[i] consists only of lowercase English letters.

Asked at 6 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate