1967. Number of Strings That Appear as Substrings in Word
</> Solution
/**
* Problem: LeetCode 1967 - Number of Strings That Appear as Substrings in Word
* Difficulty: Easy
* Language: Java
* Author: CodeByTushu
*/
class Solution {
public int numOfStrings(String[] patterns, String word) {
int count = 0;
for (String pattern : patterns) {
if (word.contains(pattern)) {
count++;
}
}
return count;
}
}
"""
Problem: LeetCode 1967 - Number of Strings That Appear as Substrings in Word
Difficulty: Easy
Language: Python
Author: CodeByTushu
"""
from typing import List
class Solution:
def numOfStrings(self, patterns: List[str], word: str) -> int:
count = 0
for pattern in patterns:
if pattern in word:
count += 1
return count
/**
* Problem: LeetCode 1967 - Number of Strings That Appear as Substrings in Word
* Difficulty: Easy
* Language: C++
* Author: CodeByTushu
*/
#include <vector>
#include <string>
using namespace std;
/**
* Problem: LeetCode 1967 - Number of Strings That Appear as Substrings in Word
* Difficulty: Easy
* Language: C++
* Author: CodeByTushu
*/
class Solution {
public:
int numOfStrings(vector<string>& patterns, string word) {
int count = 0;
for (const string& pattern : patterns) {
if (word.find(pattern) != string::npos) {
count++;
}
}
return count;
}
};
/**
* Problem: LeetCode 1967 - Number of Strings That Appear as Substrings in Word
* Difficulty: Easy
* Language: JavaScript
* Author: CodeByTushu
*/
var numOfStrings = function(patterns, word) {
let count = 0;
for (let pattern of patterns) {
if (word.includes(pattern)) {
count++;
}
}
return count;
};