Skip to content

Latest commit

 

History

History
14 lines (12 loc) · 329 Bytes

2185.md

File metadata and controls

14 lines (12 loc) · 329 Bytes

2185. Counting Words With a Given Prefix

Solution 1 (time O(mn), space O(1))

class Solution(object):
    def prefixCount(self, words, pref):
        """
        :type words: List[str]
        :type pref: str
        :rtype: int
        """
        return sum(w.startswith(pref) for w in words)