본문 바로가기
python-algorithm

leetcode 2185. Counting Words With a Given Prefix

by 무적김두칠 2022. 3. 17.

1
2
3
4
5
6
7
class Solution:
    def prefixCount(self, words: List[str], pref: str-> int:
        prefLength=len(pref)
        cnt=0
        for i in words:
            if i[:prefLength]==pref : cnt+=1
        return cnt
cs
반응형

댓글