Counting Words With a Given Prefix LeetCode solution in Java

1
class Solution {
2
public int prefixCount(String[] words, String pref) {
3
int c = 0;
4
for (String s : words) {
5
if (s.indexOf(pref) == 0) c++;
6
}
7
return c;
8
}
9
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0