LeetCode/java/counting-words-with-a-given-prefix.java
2025-01-09 10:46:25 +01:00

5 lines
166 B
Java

class Solution {
public int prefixCount(String[] words, String pref) {
return (int) (Arrays.stream(words).filter(word -> word.startsWith(pref)).count());
}
}