Beginner friendly, beats 100%
IntuitionTo check every word in the words[] array starts with the given prefix pref.Approach
Initialize a variable int count=0 to keep the track of the words in
# Intuition
 To check every word in the `words[]` array starts with the given prefix `pref`.
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
- Initialize a variable `int count=0` to keep the track of the words in the `words[]` array which start with the given prefix `pref`.
- Simply check if every word in the `words[]` array starts with the given prefix `pref` and increment the `count` variable if so.
- Use the `str.startsWith()` method to check if the given prefix `pref` is a prefix of the current word from the `words[]` array.
- Return the `count`.
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

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

# Code
```java []
class Solution {
    public int prefixCount(String[] words, String pref) {
        int count=0;
        for(String word:words)
        {
            if(word.startsWith(pref)) count++;
        }
        return count;
    }
}
```
['Java']