Easy Java Solution - Beats 100% (Runtime 0ms)
Complexity

Time complexity:
O(n), where n = words.length


Space complexity:
O(1)

Code
# Complexity
- Time complexity:
$$O(n)$$, where n = words.length

- Space complexity:
$$O(1)$$

# Code
```java []
class Solution {
    public int prefixCount(String[] words, String pref) {
        int ans = 0;
        for(int i=0; i<words.length; i++) {
            if(words[i].indexOf(pref) == 0) {
                ans++;
            }
        }
        return ans;
    }
}
```
['Java']