Counting Words With a Given Prefix
1 2 3 4 5 6 7 8 9 10 |
class Solution { public int prefixCount(String[] words, String pref) { int res = 0; for(String w : words){ if(w.startsWith(pref)) res++; } return res; } } |