题目
给你一个字符串数组 patterns
和一个字符串 word
,统计 patterns
中有多少个字符串是 word
的子字符串。返回字符串数目。
子字符串 是字符串中的一个连续字符序列。
示例1:
1 | 输入:patterns = ["a","abc","bc","d"], word = "abc" |
示例2:
1 | 输入:patterns = ["a","b","c"], word = "aaaaabbbbb" |
示例3:
1 | 输入:patterns = ["a","a","a"], word = "ab" |
提示:
1 <= patterns.length <= 100
1 <= patterns[i].length <= 100
1 <= word.length <= 100
patterns[i]
和word
由小写英文字母组成
解法
解法一:
Java
1 | public int numOfStrings(String[] patterns, String word) { |