LeetCode solutions

3194. Find Words Containing Character

My accepted C++ solution to LeetCode problem 3194, Find Words Containing Character, running in 0ms.

  • Difficulty: Easy
  • C++
  • Runtime 0ms
  • Memory 33MB

Read the problem on LeetCode View on GitHub

C++

Accepted on LeetCode — runtime 0ms, memory 33MB, accepted 2025-12-27.

cpp
class Solution {
    public:
    vector<int> findWordsContaining(vector<string>& words, char x) {
        vector<int> result;
        for (int i = 0; i < words.size(); i++) {
            if (words[i].find(x) != string::npos) {
                result.push_back(i);
            }
        }
        return result;
    }
};

Source