2255. Count Prefixes of a Given String

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2255

class Solution:
    def countPrefixes(self, words: List[str], s: str) -> int:
        return sum(s.startswith(w) for w in words)