|
| 1 | +<p>You are given a <strong>0-indexed</strong> array of strings <code>words</code> and a character <code>x</code>.</p> |
| 2 | + |
| 3 | +<p>Return <em>an <strong>array of indices</strong> representing the words that contain the character </em><code>x</code>.</p> |
| 4 | + |
| 5 | +<p><strong>Note</strong> that the returned array may be in <strong>any</strong> order.</p> |
| 6 | + |
| 7 | +<p> </p> |
| 8 | +<p><strong class="example">Example 1:</strong></p> |
| 9 | + |
| 10 | +<pre> |
| 11 | +<strong>Input:</strong> words = ["leet","code"], x = "e" |
| 12 | +<strong>Output:</strong> [0,1] |
| 13 | +<strong>Explanation:</strong> "e" occurs in both words: "l<strong><u>ee</u></strong>t", and "cod<u><strong>e</strong></u>". Hence, we return indices 0 and 1. |
| 14 | +</pre> |
| 15 | + |
| 16 | +<p><strong class="example">Example 2:</strong></p> |
| 17 | + |
| 18 | +<pre> |
| 19 | +<strong>Input:</strong> words = ["abc","bcd","aaaa","cbc"], x = "a" |
| 20 | +<strong>Output:</strong> [0,2] |
| 21 | +<strong>Explanation:</strong> "a" occurs in "<strong><u>a</u></strong>bc", and "<u><strong>aaaa</strong></u>". Hence, we return indices 0 and 2. |
| 22 | +</pre> |
| 23 | + |
| 24 | +<p><strong class="example">Example 3:</strong></p> |
| 25 | + |
| 26 | +<pre> |
| 27 | +<strong>Input:</strong> words = ["abc","bcd","aaaa","cbc"], x = "z" |
| 28 | +<strong>Output:</strong> [] |
| 29 | +<strong>Explanation:</strong> "z" does not occur in any of the words. Hence, we return an empty array. |
| 30 | +</pre> |
| 31 | + |
| 32 | +<p> </p> |
| 33 | +<p><strong>Constraints:</strong></p> |
| 34 | + |
| 35 | +<ul> |
| 36 | + <li><code>1 <= words.length <= 50</code></li> |
| 37 | + <li><code>1 <= words[i].length <= 50</code></li> |
| 38 | + <li><code>x</code> is a lowercase English letter.</li> |
| 39 | + <li><code>words[i]</code> consists only of lowercase English letters.</li> |
| 40 | +</ul> |
0 commit comments