Return all words that contain a given character at least once.
You are given an array of lowercase words and a single character x.
Return the indices of all words that contain x at least once, in the same order as the input.
A word is selected if any character in the word matches x exactly.
words: an array of stringsx: a characterx.1 <= words.length <= 1001 <= words[i].length <= 100x is a single lowercase English letterThe task is a straightforward scan through each string and keep the positions of matching words.
words: array of lowercase stringsx: single lowercase character1 <= words.length <= 1001 <= words[i].length <= 100x is one lowercase English letterExample 1
Input
words = ["leet","code"], x = "e"
Output
[0,1]
Explanation
Both "leet" and "code" contain the character 'e'.
Example 2
Input
words = ["abc","bcd","aaaa","cbc"], x = "a"
Output
[0,2]
Explanation
Only "abc" and "aaaa" contain 'a'.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.