python-algorithm
leetcode 1967. Number of Strings That Appear as Substrings in Word
무적김두칠
2023. 2. 3. 17:49
https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/description/
Number of Strings That Appear as Substrings in Word - LeetCode
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. E
leetcode.com
1
2
3
4
5
6
7
8
|
class Solution:
def numOfStrings(self, patterns: List[str], word: str) -> int:
answer = 0
for pattern in patterns:
if pattern in word:
answer +=1
return answer
|
cs |
반응형