forked from int28h/JavaTasks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12.java
More file actions
13 lines (11 loc) · 756 Bytes
/
12.java
File metadata and controls
13 lines (11 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
/*
Create a stream that will detect bad words in a text according to a bad words list.
All words in the text are divided by whitespaces (always only one whitespace between two words).
After calling collect(Collectors.toList()) the stream must return the list of bad words which were found in the text.
The result should be dictionary ordered (in lexicographical order, i.e. sorted) and bad words shouldn't repeat.
Important. You need return a prepared stream from the template method, not a list of bad words.
Pay attention to the method template. Do not change it!
*/
public static Stream<String> createBadWordsDetectingStream(String text, List<String> badWords) {
return badWords.stream().filter((s) -> text.contains(s)).distinct().sorted();
}