Easy C++ Beats 100%  
IntuitionThe problem requires counting how many strings in the listwordsstart with a specific prefix pref.
The solution involves checking each string in the lis
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem requires counting how many strings in the list` words `start with a specific prefix `pref.`
The solution involves checking each string in the list to see if its first few characters match the prefix. If they do, the count is incremented.

# Approach
<!-- Describe your approach to solving the problem. -->
1. Iterate Through Words:

  *  Loop through each string in the `words` list.
  *  For each word, ensure that it is at least as long as the prefix to avoid out-of-bound checks.
2. Check Prefix Using `find:`

    * Use the `string::find` function to determine if the prefix is present at the start of the string (i.e., at position 0). If true, increment the count.
3. Handle Edge Cases:

   * Skip checking if the prefix is longer than the current word, as it cannot match.
4. Return the Count:

  *  After iterating through all words, return the total count of strings starting with the given prefix.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
 - O(n)


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

# Code
```cpp []
class Solution {
public:
    int prefixCount(vector<string>& words, string pref) {
        int n = words.size(); // Get the number of words in the list
        int count = 0;        // Initialize a counter to keep track of matches

        // Iterate through each word in the list
        for (int i = 0; i < n; i++) {
            // If the prefix length is greater than the current word's length,
            // skip this word since the prefix cannot match
            if (pref.size() > words[i].size()) {
                continue;
            }

            // Check if the prefix exists at the start of the word
            // 'find(pref) == 0' ensures the prefix is found at index 0
            if (words[i].find(pref) == 0) {
                count++; // Increment the counter if the prefix matches
            }
        }

        return count; // Return the total count of words with the prefix
    }
};

```
['Array', 'String', 'String Matching', 'Counting', 'C++']