|
4 | 4 | **
|
5 | 5 | * You are given a 0-indexed array of strings words and a character x.
|
6 | 6 | * Return an array of indices representing the words that contain the character x.
|
7 |
| - * |
| 7 | + * |
8 | 8 | * Note that the returned array may be in any order.
|
9 |
| - * |
| 9 | + * |
10 | 10 | * Example 1:
|
11 | 11 | * Input: words = ["leet","code"], x = "e"
|
12 | 12 | * Output: [0,1]
|
13 | 13 | * Explanation: "e" occurs in both words: "leet", and "code". Hence, we return indices 0 and 1.
|
14 |
| - * |
| 14 | + * |
15 | 15 | * Example 2:
|
16 | 16 | * Input: words = ["abc","bcd","aaaa","cbc"], x = "a"
|
17 | 17 | * Output: [0,2]
|
18 | 18 | * Explanation: "a" occurs in "abc", and "aaaa". Hence, we return indices 0 and 2.
|
19 |
| - * |
| 19 | + * |
20 | 20 | * Example 3:
|
21 | 21 | * Input: words = ["abc","bcd","aaaa","cbc"], x = "z"
|
22 | 22 | * Output: []
|
23 | 23 | * Explanation: "z" does not occur in any of the words. Hence, we return an empty array.
|
24 |
| - * |
| 24 | + * |
25 | 25 | * Constraints:
|
26 |
| - * - 1 <= words.length <= 50 |
27 |
| - * - 1 <= words[i].length <= 50 |
28 |
| - * - x is a lowercase English letter. |
29 |
| - * - words[i] consists only of lowercase English letters. |
30 |
| - * |
| 26 | + * • 1 <= words.length <= 50 |
| 27 | + * • 1 <= words[i].length <= 50 |
| 28 | + * • x is a lowercase English letter. |
| 29 | + * • words[i] consists only of lowercase English letters. |
| 30 | + * |
31 | 31 | * Hint 1: Use two nested loops.
|
32 | 32 | **
|
33 | 33 | * https://leetcode.com/problems/find-words-containing-character/
|
|
0 commit comments