✅Easy to understand✅ Beats 100%
Code
![image.png](https://assets.leetcode.com/users/images/0e4280a3-55d3-4d5d-9e18-b0177c3060f4_1736389313.9701693.png)


# Code
```cpp []
class Solution {
public:
    int prefixCount(vector<string>& words, string pref) {
        int c = 0;
        int n = pref.length();
        for (const string& w : words) {
            if (w.size() >= n && w.compare(0, n, pref) == 0) {
                c++;
            }
        }
        return c;
    }
};

```

```python []
class Solution:
    def prefixCount(self, words: list[str], pref: str) -> int:
        c = 0
        n = len(pref)
        for word in words:
            if len(word) >= n and word[:n] == pref:
                c += 1
        return c

```
```Java []
class Solution {
    public int prefixCount(String[] words, String pref) {
        int c = 0;
        int n = pref.length();
        for (String w : words) {
            if (w.length() >= n && w.startsWith(pref)) {
                c++;
            }
        }
        return c;
    }
}

```
![download.jpeg](https://assets.leetcode.com/users/images/5e54ce8f-85c3-42eb-b14a-80d9b90e23c0_1736389445.0482821.jpeg)


['C++', 'Java', 'Python3']