Easy solution || Beats 100% 
IntuitionMatching every character of pref with the the prefixes of strings present in words array.Approach
Iterate through every element in the array. And initi
![{B1FAC10B-CDD1-4F1F-BB50-349308744B30}.png](https://assets.leetcode.com/users/images/07a653ba-1329-4b36-bff2-0028411d5452_1736422431.2019923.png)

# Intuition
Matching every character of pref with the the prefixes of strings present in words array.

# Approach
1. Iterate through every element in the array. And initialize a counter cnt to return the final answer.
2. Now check is the pref is a prefix of words[i] or not. If it is a prefix than increase the cnt.
3. To check initialize a pointer (j = 0) over pref and string and check one by one if they match than increment the pointer j (j++) otherwise return false.

# Complexity
- Time complexity: **O(n.m)**
where n = size of array and m = length of pref string.

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

# Code
```cpp []
class Solution {
public:
    bool check(string s1, string s2){
        int j = 0;  

        while(j < s2.size()){
            if(s1[j] != s2[j]) return false;
            else j++;  
        }
        return true; 
    }
    int prefixCount(vector<string>& words, string pref) {
        int n = words.size();
        int cnt = 0; 
        for(int i = 0; i < n; i++){
            if(check(words[i], pref)) cnt++;
        }
        return cnt;
    }
};
```

Upvote if it helps :)



['C++']