Number of Strings That Appear as Substrings in Word

Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word.

A substring is a contiguous sequence of characters within a string.

Example 1
Inputpatterns = ["a","abc","bc","d"], word = "abc"
Output3
The strings "a", "abc", and "bc" appear as substrings in "abc", while "d" does not.
Example 2
Inputpatterns = ["a","b","c"], word = "aaaaabbbbb"
Output2
The strings "a" and "b" appear as substrings in "aaaaabbbbb", while "c" does not.

Constraints

  • 1 <= patterns.length <= 100
  • 1 <= patterns[i].length <= 100
  • 1 <= word.length <= 100
  • patterns[i] and word consist of lowercase English letters.

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate