14 lines
344 B
Python
14 lines
344 B
Python
# https://leetcode.com/problems/counting-words-with-a-given-prefix
|
|
|
|
from typing import List
|
|
|
|
class Solution:
|
|
def prefixCount(self, words: List[str], pref: str) -> int:
|
|
result = 0
|
|
l = len(pref)
|
|
for word in words:
|
|
if len(word) >= l and word[:l] == pref:
|
|
result += 1
|
|
return result
|
|
|
|
|