Beginner Approach || Brute Force || Easy C++ Code
IntuitionThe function iterates through each string in the words vector and checks if it starts with the given prefix pref.Approach
Iterate through each word: Lo
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The function iterates through each string in the words vector and checks if it starts with the given prefix pref.

# Approach
<!-- Describe your approach to solving the problem. -->
1. Iterate through each word: Loop through each string in the words vector.
2. Check for prefix: For each word, use find(pref) to determine if the word starts with the prefix pref. This is done by checking if find(pref) == 0, which means the prefix is found at the beginning of the word.
3. Count matches: Every time a word matches the prefix, increment the counter.
4. Return the count: After processing all the words, return the total count of words that start with the given prefix.

# Complexity
- Time complexity: $$O(N * M)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: $$O(1)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int prefixCount(vector<string>& words, string pref) {
        int n = words.size();
        int count =0;
        for(int i=0;i<n;i++)
        {
            if(words[i].find(pref)==0) count++;
        }
        return count;
    }
};
```
['Array', 'String', 'String Matching', 'C++']