Number of Strings That Appear as Substrings in Word
You can implement this by iterating through the patterns and checking if each pattern exists as a substring in the given word. If a pattern is found as a substring in the word, you can increment a count. Finally, return the count.
Here’s the code:
|
|
This code loops through each pattern and uses the in
operator to check if it’s a substring of word
. The time complexity of this solution is O(n * m), where n is the length of patterns
and m is the length of word
.