Beats 100%✅✅|| Simple O(NM)
IntuitionWe iterate through each word in the given list and check if the word starts with the given prefix.Approach
Initialize a counter cnt to 0.
Iterate throu
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We iterate through each word in the given list and check if the word starts with the given prefix.

# Approach
<!-- Describe your approach to solving the problem. -->
1. Initialize a counter `cnt` to 0.
2. Iterate through each word in the list.
3. Use two pointers, one for the word and another for the prefix.
4. Compare characters one by one until the prefix is fully matched or characters mismatch.
5. If the prefix is matched, increment the counter.
6. Return the counter.

# Complexity
- Time complexity:
$$O(n \cdot m)$$, where \(n\) is the number of words and \(m\) is the average length of the words or the prefix.

- Space complexity:
$$O(1)$$, as we are using constant extra space.

# Code
```cpp []
class Solution {
public:
    int prefixCount(vector<string>& words, string pref) {
        int cnt = 0;
        for (auto it : words) {
            int i = 0, j = 0;
            while (i < it.size() && j < pref.size()) {
                if (it[i] == pref[j]) {
                    i++;
                    j++;
                } else break;
            }
            if (j == pref.size()) cnt++;
        }
        return cnt;
    }
};
```
```Java []
class Solution {
    public int prefixCount(String[] words, String pref) {
        int cnt = 0;
        for (String word : words) {
            int i = 0, j = 0;
            while (i < word.length() && j < pref.length()) {
                if (word.charAt(i) == pref.charAt(j)) {
                    i++;
                    j++;
                } else break;
            }
            if (j == pref.length()) cnt++;
        }
        return cnt;
    }
}

```
```Python []
class Solution:
    def prefixCount(self, words: List[str], pref: str) -> int:
        cnt = 0
        for word in words:
            i, j = 0, 0
            while i < len(word) and j < len(pref):
                if word[i] == pref[j]:
                    i += 1
                    j += 1
                else:
                    break
            if j == len(pref):
                cnt += 1
        return cnt

```
['Array', 'String', 'Python', 'C++', 'Java']