程式語言 - LeetCode - C++ - 1967. Number of Strings That Appear as Substrings in Word



題目:


解答:

class Solution {
public:
    int numOfStrings(vector<string>& patterns, string word) {
        int ans = 0;

        for (auto& s : patterns) {
            if (word.find(s) != string::npos) {
                ans += 1;
            }
        }

        return ans;
    }
};