Just 3 lines code🤯❤️‍🔥Most easy solution✅👨🏻‍💻Beats 💯% solutions on LeetCode🐦‍🔥
IntuitionFirst of all on reading the question I realised that we just need to count the number of words in the given array which have given word as prefix and t
# Intuition
First of all on reading the question I realised that we just need to count the number of words in the given array which have given word as prefix and then simply return that count. 

![image.png](https://assets.leetcode.com/users/images/f6df6932-1062-4153-ab9a-76fe677f91ec_1736434709.4123886.png)


# Approach
- First create a variable of int data type named `count=0`.
- Now traverse through the given vector `words` and for each word check if the starting of the word contains the given word `pref` as prefix using `substr()` function.
- Increment the `count`, if the above condition is satisfied.
- Finally, return `count`.

# Complexity
- **Time complexity:** O(n*m)⏳

- **Space complexity:** O(1)🚀

# Code
```cpp []
class Solution {
public:
    int prefixCount(vector<string>& words, string pref) {
        int count=0;
        for(auto x: words){
            count+=(x.substr(0,pref.size())==pref);
        }
        return count;
    }
};
```

𝙋𝙡𝙚𝙖𝙨𝙚 𝙪𝙥𝙫𝙤𝙩𝙚👍 𝙞𝙛 𝙮𝙤𝙪 𝙛𝙤𝙪𝙣𝙙 𝙞𝙩 𝙝𝙚𝙡𝙥𝙛𝙪𝙡 𝙜𝙪𝙮𝙨 𝙖𝙨 𝙞𝙩 𝙬𝙤𝙪𝙡𝙙 𝙚𝙣𝙘𝙤𝙪𝙧𝙖𝙜𝙚 𝙢𝙚 𝙩𝙤 𝙥𝙤𝙨𝙩 𝙢𝙤𝙧𝙚 𝙨𝙪𝙘𝙝 𝙨𝙤𝙡𝙪𝙩𝙞𝙤𝙣𝙨. 😇
['Array', 'String', 'C++']