Skip to content

Commit 3cee3ae

Browse files
authored
Create 2942. Find Words Containing Character (#803)
2 parents c5935c0 + 9e5503d commit 3cee3ae

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

2942. Find Words Containing Character

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
vector<int> findWordsContaining(vector<string>& words, char x)
4+
{
5+
vector<int> ans;
6+
int n = words.size();
7+
for(int i = 0; i < n; i++)
8+
{
9+
unordered_set<char>st(begin(words[i]), end(words[i]));
10+
if(st.count(x)) ans.push_back(i);
11+
}
12+
return ans;
13+
}
14+
};

0 commit comments

Comments
 (0)