给你一个字符串数组 patterns
和一个字符串 word
,统计 patterns
中有多少个字符串是 word
的子字符串。返回字符串数目。
子字符串 是字符串中的一个连续字符序列。
1967. 作为子字符串出现在单词中的字符串数目 – 力扣(Leetcode)


思路:
直接判断字符是否在字符串中即可。
python3实现:
class Solution:
def numOfStrings(self, patterns: List[str], word: str) -> int:
count = 0
for elem in patterns:
if elem in word:
count += 1
return count
