LeetCode 2185.统计包含给定前缀的字符串

LeetCode 2185.统计包含给定前缀的字符串

python用startswith方法一行结束,c++17还没有startswith方法。

    def prefixCount(self, words: List[str], pref: str) -> int:
        return len([x for x in words if x.startswith(pref)])