2025-08-17 19:10:32 +0300 MSK

Counting Words With a Given Prefix

Code

class Solution:
    def prefixCount(self, words: List[str], pref: str) -> int:
        res = 0
        for word in words:
            if word.startswith(pref):
                res += 1
        return res