본문 바로가기
python-algorithm

leetcode 1967. Number of Strings That Appear as Substrings in Word

by 무적김두칠 2023. 2. 3.

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
반응형

'python-algorithm' 카테고리의 다른 글

leetcode 819. Most Common Word  (0) 2023.02.07
leetcode 937. Reorder Data in Log Files  (0) 2023.02.07
백준 27332 11 月 (November)  (0) 2023.02.01
백준 27294 몇개고?  (0) 2023.01.31
백준 27328 三方比較 (Three-Way Comparison)  (0) 2023.01.31

댓글