Skip to content

Instantly share code, notes, and snippets.

@Remonhasan
Created May 29, 2024 11:47
Show Gist options
  • Save Remonhasan/83893d1841f457f2576fdaa4b1c553c3 to your computer and use it in GitHub Desktop.
Save Remonhasan/83893d1841f457f2576fdaa4b1c553c3 to your computer and use it in GitHub Desktop.
Leetcode 2942 : Find Words Containing Character
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;
}
};
@Remonhasan
Copy link
Author

Find the character is exists or not in a string : STL concepts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment