Find Words Containing Character

You are given a 0-indexed array of strings words and a character x. Return an array of the indices of the words that contain the character x. The returned array may be in any order.

30:00

Find Words Containing Character
easy
Free written solution
Topics
Companies

You are given a 0-indexed array of strings words and a character x. Return an array of the indices of the words that contain the character x. The returned array may be in any order.

Example 1:
Input: {"words":["leet","code"],"x":"e"}
Output: [0,1]
Constraints:
  • 1≤words.length≤501 \leq \text{words.length} \leq 50

  • 1≤words[i].length≤501 \leq \text{words}[i].\text{length} \leq 50

  • xx is a lowercase English letter.

  • words[i]\text{words}[i] consists only of lowercase English letters.

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"words":["leet","code"],"x":"e"}

Look for the letter 'e' in each of the 2 words. result starts empty.

looking for

e

words

0

l
e
e
t

1

c
o
d
e

result

[ ]

Variables
VariableValue
xe
result[]
DepthFunction Call
Stack empty
0/11