Exactly did what was asked to check if prefix is same & did some optimization before check||Runs 0ms
Approach
Little Optimization: First just little check before checking the whole prefix presence if their first character same and length should be >= pref
Compl
![image.png](https://assets.leetcode.com/users/images/9e8a635d-6d9d-4f98-bd95-f686123ff393_1736382891.6574821.png)

# Approach
<!-- Describe your approach to solving the problem. -->
- Little Optimization: First just little check before checking the whole prefix presence if their first character same and length should be >= pref

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

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

# Code
```cpp []
#pragma GCC optimize("O3,unroll-loops,Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
static const auto harsh = []() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

class Solution {
public:
    int prefixCount(vector<string>& words, string pref) {
        int count = 0;

        for(int i = 0; i<words.size(); i++){
            // Little Optimization: First just little check if their first character same and length should be >= pref
            if(words[i][0] == pref[0] && pref.length() <= words[i].length()){
                int j = 0;
                while(j<words[i].length() && j < pref.length() && pref[j] == words[i][j]){
                        j++;
                }
                // If the whole prefix found then count
                if(j == pref.length()){
                    count++;
                }
            }
        }
        return count;
    }
};
```
![image.png](https://assets.leetcode.com/users/images/8f45f11e-c625-4599-9b28-e830bc2c66d0_1724569032.8579876.png)
['Array', 'String', 'String Matching', 'C++']