Algorithms
Easy
2942
3194
Find Words Containing Character
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:

Input: words = ["leet","code"], x = "e"
Output: [0,1]
Explanation: "e" occurs in both words: "leet", and "code". Hence, we return indices 0 and 1.

Example 2:

Input: words = ["abc","bcd","aaaa","cbc"], x = "a"
Output: [0,2]
Explanation: "a" occurs in "abc", and "aaaa". Hence, we return indices 0 and 2.

Example 3:

Input: words = ["abc","bcd","aaaa","cbc"], x = "z"
Output: []
Explanation: "z" does not occur in any of the words. Hence, we return an empty array.


Constraints:

1 <= words.length <= 50
1 <= words[i].length <= 50
x is a lowercase English letter.
words[i] consists only of lowercase English letters.
"""
class Solution:
    def findWordsContaining(self, words: List[str], x: str) -> List[int]:
        
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:

Input: words = ["leet","code"], x = "e"
Output: [0,1]
Explanation: "e" occurs in both words: "leet", and "code". Hence, we return indices 0 and 1.

Example 2:

Input: words = ["abc","bcd","aaaa","cbc"], x = "a"
Output: [0,2]
Explanation: "a" occurs in "abc", and "aaaa". Hence, we return indices 0 and 2.

Example 3:

Input: words = ["abc","bcd","aaaa","cbc"], x = "z"
Output: []
Explanation: "z" does not occur in any of the words. Hence, we return an empty array.


Constraints:

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


Please complete the code below to solve above prblem:
```python
class Solution:
    def findWordsContaining(self, words: List[str], x: str) -> List[int]:
        
```

my_solution = Solution()

test_input = { "words": ["leet","code"], "x": "e" }
assert my_solution.findWordsContaining(**test_input) == [0,1]

test_input = { "words": ["abc","bcd","aaaa","cbc"], "x": "a" }
assert my_solution.findWordsContaining(**test_input) == [0,2]

test_input = { "words": ["abc","bcd","aaaa","cbc"], "x": "z" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["sgtkshnss","m","ryvbkyvuz","ezittyjwgb","wudlwg"], "x": "x" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["lkwnhpbj","tlohm","juazsb","f","rq"], "x": "v" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["aaa","imvtfjmxr","wbzfoovjnf","hqwrwmi"], "x": "c" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["utyeachht","bgpkcs","skeecqvvvw","nccrd"], "x": "i" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["alcpxexztg","r"], "x": "h" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["ekcpg","pdknua","fot","janppw","ofomkfvx"], "x": "g" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["dq","rlvopu"], "x": "d" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["wzppkd","jxvk","zaztizmwuv","hvcdtobr"], "x": "b" }
assert my_solution.findWordsContaining(**test_input) == [3]

test_input = { "words": ["y","hs","qznrkpi"], "x": "v" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["pze","yojczsb","mjvyr","i","xsygks"], "x": "q" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["qsgtjagcu","m"], "x": "e" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["kidtwmw","ogh","trdedlh","wwbtlindg","naoylytpof","ujcbzwzkm","doamcoxdv"], "x": "o" }
assert my_solution.findWordsContaining(**test_input) == [1,4,6]

test_input = { "words": ["tsmeupctki"], "x": "t" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["dqxlbljmpf","uvdzfoiqg","jsnbnx","fbedae","nodewb","o","ivepktj"], "x": "g" }
assert my_solution.findWordsContaining(**test_input) == [1]

test_input = { "words": ["fjlmmecm","sautsoorhl","n","hsyco","amlukrpjpv","rmhdnj","g"], "x": "e" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["khjchmeciv","vgx","xghr","bbufgegu","qyfxu"], "x": "r" }
assert my_solution.findWordsContaining(**test_input) == [2]

test_input = { "words": ["jhtcugtcpl","bvhlgmmla","ntfkwzite","imbtzafaj","sdl","t"], "x": "m" }
assert my_solution.findWordsContaining(**test_input) == [1,3]

test_input = { "words": ["kxoziqoafc","vifcxifq"], "x": "q" }
assert my_solution.findWordsContaining(**test_input) == [0,1]

test_input = { "words": ["ckfkjjsonl","scaaug","rmvqzyiwc","a","smymw"], "x": "p" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["t","exo","npr","skd","bxpmbu"], "x": "e" }
assert my_solution.findWordsContaining(**test_input) == [1]

test_input = { "words": ["eulsl","fwooyct","ypytexil"], "x": "c" }
assert my_solution.findWordsContaining(**test_input) == [1]

test_input = { "words": ["nhd","zheyegi","ogz","fpybmcc","ntbbwtde"], "x": "g" }
assert my_solution.findWordsContaining(**test_input) == [1,2]

test_input = { "words": ["gwzvusl","upcpvbfyxy","hg","yu","wsfqgzhh","zgphqacsyo"], "x": "o" }
assert my_solution.findWordsContaining(**test_input) == [5]

test_input = { "words": ["uiovpph","xxj","uwzxzvkobk"], "x": "r" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["abtrpwo","sgaegnavk","pfmv"], "x": "z" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["m","fxtphsdmgy","otq","vwuhhnebr","yen"], "x": "y" }
assert my_solution.findWordsContaining(**test_input) == [1,4]

test_input = { "words": ["irlzx","lbrknhl","roupfj","fskaieszo","nz","ijfyejq"], "x": "e" }
assert my_solution.findWordsContaining(**test_input) == [3,5]

test_input = { "words": ["raavc","tx"], "x": "l" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["bkpuvcrexw","hxtbcdprhr","ovt","xgurm","pjcz","sbhwpjmyz"], "x": "g" }
assert my_solution.findWordsContaining(**test_input) == [3]

test_input = { "words": ["f","xlmy","akbiqa","fobo"], "x": "s" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["mhan"], "x": "a" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["uisx"], "x": "o" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["znqdolksyn","keewspe","ffod","lah","gadhym","awnyymd","fvkl"], "x": "v" }
assert my_solution.findWordsContaining(**test_input) == [6]

test_input = { "words": ["ftujx","dnbwrurk","t","x","zjzhdl","jc"], "x": "t" }
assert my_solution.findWordsContaining(**test_input) == [0,2]

test_input = { "words": ["zrwf","thp","qecwlnq","w","teetdaxx"], "x": "t" }
assert my_solution.findWordsContaining(**test_input) == [1,4]

test_input = { "words": ["xyzgb","qflfrfqgaf"], "x": "l" }
assert my_solution.findWordsContaining(**test_input) == [1]

test_input = { "words": ["shnjr","qfvop"], "x": "y" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["fmwclqh","xbphhgreze","yi","gmtzrfdab","uicqa","n"], "x": "i" }
assert my_solution.findWordsContaining(**test_input) == [2,4]

test_input = { "words": ["jgkv","njhwihtv","v"], "x": "z" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["tqkwoofh","bcgngl","frjpqgrr","drvb"], "x": "x" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["npkvocbw","tn","dp","c","g","fsxvzcnty","ywnf"], "x": "k" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["leompil","vta","fzrsps","yp","bykmgwgk"], "x": "o" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["umq","c","ctuh","eadzeuui","tabum","isuct"], "x": "p" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["rnmpdkmrnb","icxxsvss","h","gd"], "x": "s" }
assert my_solution.findWordsContaining(**test_input) == [1]

test_input = { "words": ["ft","hsjf","e","xi"], "x": "w" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["ozf","xkehlkgp","vliewlbv","okgaahah"], "x": "b" }
assert my_solution.findWordsContaining(**test_input) == [2]

test_input = { "words": ["gbktzr","kbamubluz","dwoi","crhldx","idjronpded","rqaz"], "x": "c" }
assert my_solution.findWordsContaining(**test_input) == [3]

test_input = { "words": ["gvbzqcb","rwtbra","iuijl","qbmpbi"], "x": "c" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["lsh","szhxhcdc","quem","zupiydjeqp","czxyvysrrb","aqnlqtnfiv"], "x": "p" }
assert my_solution.findWordsContaining(**test_input) == [3]

test_input = { "words": ["leuah","liaoczeuch","ol","ify","layh","ifzudwuybw","x"], "x": "p" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["ksdpwwho","ktunsikyu"], "x": "a" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["vpypaumzlp","kqrb","pgw"], "x": "l" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["jkrpnx","c","kqi","xrsaviyusg","waoxq","fld","otxfgcp"], "x": "l" }
assert my_solution.findWordsContaining(**test_input) == [5]

test_input = { "words": ["tetw","zl","wd","hnkxoxlnz","dexgufawjd","oolpr","yyfwizbsl"], "x": "p" }
assert my_solution.findWordsContaining(**test_input) == [5]

test_input = { "words": ["hihprd","kitgiflc","nr","idduuahfkm"], "x": "x" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["flfxeca","g"], "x": "e" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["st","betf","ipacxza","jpnw"], "x": "r" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["cvuxnzaib","c","tiytr","yiav","hp","yg"], "x": "d" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["yz","k","midujexvn","kwcgbht"], "x": "y" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["qcxobdaxv"], "x": "q" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["b","shrexcf","ve","eqpbnuy","qdhahodo","aerdf","bdjlaakagk"], "x": "p" }
assert my_solution.findWordsContaining(**test_input) == [3]

test_input = { "words": ["ympv"], "x": "q" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["thfy","lnfzoyafiy","qmc","boijcl","pvbzmsa","yjarwylcyc"], "x": "e" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["hqptwi"], "x": "o" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["bv","xgrhtjnxh","fdtljkxa","po","hejof"], "x": "k" }
assert my_solution.findWordsContaining(**test_input) == [2]

test_input = { "words": ["mfdrclyx","pith"], "x": "e" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["bxeblhrl","o","uvv"], "x": "b" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["giygz"], "x": "u" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["ffqw","nykncbxrqi","pgzy","of","oye","f"], "x": "g" }
assert my_solution.findWordsContaining(**test_input) == [2]

test_input = { "words": ["jjnh","nrbh","z"], "x": "l" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["gdzkdtvrm","ps","kp","sbdlkac","s","bt"], "x": "n" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["hpsk","stjltzz","gvbjwzktgg","hmeovbxvv","gqaxqoshbh","mqnwyabqq","sq"], "x": "f" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["gwmg","qdjeaxgc","rlajltxpd","d"], "x": "g" }
assert my_solution.findWordsContaining(**test_input) == [0,1]

test_input = { "words": ["dupx","r","j","wq","macfcfoz"], "x": "r" }
assert my_solution.findWordsContaining(**test_input) == [1]

test_input = { "words": ["rmypzoyto","wvhtrbuz","dgt","tmhqswmkx","trpjwzitp","tbetdxic"], "x": "t" }
assert my_solution.findWordsContaining(**test_input) == [0,1,2,3,4,5]

test_input = { "words": ["vpkjymgdb","s","gv","geie"], "x": "g" }
assert my_solution.findWordsContaining(**test_input) == [0,2,3]

test_input = { "words": ["epnmbry","hhfhprvqba"], "x": "l" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["zst","mjzbdxsks","dza","neqj","oqeilr"], "x": "d" }
assert my_solution.findWordsContaining(**test_input) == [1,2]

test_input = { "words": ["ffruqk","sse","cyj","tntq","mibbhhpce"], "x": "c" }
assert my_solution.findWordsContaining(**test_input) == [2,4]

test_input = { "words": ["vumzrbe","qudq","qfrt"], "x": "u" }
assert my_solution.findWordsContaining(**test_input) == [0,1]

test_input = { "words": ["wcrrprvu","fizkw","vzcjxhjy","e"], "x": "r" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["gjk","vri"], "x": "n" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["fds","vbmg","p","iesyvc","wgmyxhoo","yfllvzr"], "x": "f" }
assert my_solution.findWordsContaining(**test_input) == [0,5]

test_input = { "words": ["mifbjo","kpjlwfbas","skhueysodn","zeewicisy"], "x": "g" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["pvkmoccv","j"], "x": "y" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["s","uhcfwsssbe","iwofeukmx","yfta","ovrdcb","psnje"], "x": "s" }
assert my_solution.findWordsContaining(**test_input) == [0,1,5]

test_input = { "words": ["klpzrjw","qmrhbpa"], "x": "v" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["fzegksjmw","masiwhjue","gngsht","xwvmp","aahn","dwxr"], "x": "c" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["mveahpesx","tsqds","g","mux","bivffitjx","zfsqdje"], "x": "f" }
assert my_solution.findWordsContaining(**test_input) == [4,5]

test_input = { "words": ["c"], "x": "a" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["jzmhnhqkq"], "x": "a" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["cfdgbc","ltpvko","batjenrlq","edwefhw"], "x": "t" }
assert my_solution.findWordsContaining(**test_input) == [1,2]

test_input = { "words": ["smlcojfydr","slb"], "x": "r" }
assert my_solution.findWordsContaining(**test_input) == [0]

test_input = { "words": ["lnjimir"], "x": "x" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["do"], "x": "e" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["xyyvbxsb","dc","mmqpb","mmbwv","wdreyof","kpk","reeb"], "x": "l" }
assert my_solution.findWordsContaining(**test_input) == []

test_input = { "words": ["ytvyknnmzv","jsoe","wctzk"], "x": "i" }
assert my_solution.findWordsContaining(**test_input) == []