1967. Number of Strings That Appear as Substrings in Word ¶ Time: $O(n\log^* n)$ Space: $O(n)$ C++JavaPython 1 2 3 4 5 6 7 8class Solution { public: int numOfStrings(vector<string>& patterns, string word) { return ranges::count_if(patterns, [&word](const string& pattern) { return word.find(pattern) != word.npos; }); } }; 1 2 3 4 5class Solution { public int numOfStrings(String[] patterns, String word) { return (int) Arrays.stream(patterns).filter(pattern -> word.contains(pattern)).count(); } } 1 2 3class Solution: def numOfStrings(self, patterns: list[str], word: str) -> int: return sum(pattern in word for pattern in patterns)