Created
May 29, 2024 11:47
-
-
Save Remonhasan/83893d1841f457f2576fdaa4b1c553c3 to your computer and use it in GitHub Desktop.
Leetcode 2942 : Find Words Containing Character
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
vector<int> findWordsContaining(vector<string>& words, char x) { | |
vector<int> wordIndex; | |
for (int i = 0; i < words.size(); ++i) { | |
if (find(words[i].begin(), words[i].end(), x) != words[i].end()) { | |
wordIndex.push_back(i); | |
} | |
} | |
return wordIndex; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Find the character is exists or not in a string : STL concepts