> For the complete documentation index, see [llms.txt](https://leetcode.realtemirov.uz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://leetcode.realtemirov.uz/problems/2185.-counting-words-with-a-given-prefix.md).

# 2185. Counting Words With a Given Prefix

🟩 Easy

## Solution

My Solution

```go
func prefixCount(words []string, pref string) int {
    count := 0
    for _, word := range words {
        if len(word) >= len(pref) && word[:len(pref)] == pref {
            count++
        }
    }

    return count
}
```

![result](https://600345290-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrSK2xH3txU3tYyDsT8mQ%2Fuploads%2Fgit-blob-67d8a20c9bb834853068625bf39c2365121fbce6%2F2185.png?alt=media)

Leetcode: [link](https://leetcode.com/problems/counting-words-with-a-given-prefix/description/)
