3 ms·
In fairness, you are omitting the list instantiation, and collecting only a count rather than an assignment of results. Apples to apples, your alternative algo
by StevePerkins 3y ago
In fairness, you are omitting the list instantiation, and collecting only a count rather than an assignment of results. Apples to apples, your alternative algorithm would be implemented like this:
words.stream().filter(w -> !w.isEmpty()).count()
Which is hardly any longer, and arguably more readable intent with the English word "filter".