Refactor to stream. URL: https://leetcode.com/problems/counting-words-with-a-given-prefix/ Signed-off-by: Matej Focko <me@mfocko.xyz>
5 lines
166 B
Java
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());
|
|
}
|
|
}
|