🔥Easy Lightning-Fast Prefix Counter: Beats 100% in Runtime! 🚀
IntuitionThe goal is to count the number of strings in the given list of words that start with the specified prefix. Since prefixes are always located at the be
# Intuition
The goal is to count the number of strings in the given list of words that start with the specified prefix. Since prefixes are always located at the beginning of the string, we can iterate over the words and compare their first characters with the prefix until we find a mismatch or confirm the prefix matches.

# Approach
1.Initialize Count: Start with a counter count initialized to 0 to keep track of the number of words that match the prefix.
2.Iterate Through Words: Loop through each word in the given list of words.
3.Compare Prefix: For each word, compare its first len characters (where len is the length of the prefix) with the prefix.
4.Use a nested loop to compare character by character.
If a mismatch is found, break out of the inner loop and skip to the next word.
5.Increment Count: If no mismatch is found, increment the count as the word starts with the given prefix.
Return Count: Finally, return the total count after all words have been checked.
This approach ensures that we carefully evaluate each word for the prefix match while maintaining simplicity in implementation.

# Complexity
- Time complexity:
The time complexity is O(n * m), where n is the number of words in the list, and m is the length of the prefix.
This is because we compare up to m characters for each of the n words.

- Space complexity:
The space complexity is O(1) as we are not using any additional data structures and only keeping track of a few variables.

# Code
```cpp []
class Solution {
public:
    int prefixCount(vector<string>& words, string pref) {
        int count = 0;
        int len = pref.length();
        for(string word: words){
            bool flag = false;
            for(int i =0; i<len; i++){
                if(word[i]!=pref[i]){
                    flag = true;
                    break;
                }
            }
            if(flag==false){
                count++;
            }
        }
        return count;
    }
};
```
['C++']