Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This is still O(array1.length * array2.length) - just as yours.
Replacing loops with streams is not taking away complexity.
Yes it is. The list after the filtering is not gauranteed to be sorted.
See my reply john777
Cool so to explain the filter function a little. The filter function takes in a function that returns TRUE or FALSE. The inner lambda expression (as a whole) returns a boolean VALUE (Arrays.stream(array2).anyMatch(s -> s.contains(str)).
For example I can write
boolean matchedResult = memberNames.stream().anyMatch((s) -> s.startsWith("filtered-strings-have-this-text"));
Notice again that matchedResults is of a boolean type, although anyMatch takes in a function as an argument, it returns a definate answer. (true or false)
The magic happens because this value (str) in the filter function satisfies the condition f(str) -> True or False.
Took me a little while to wrap my head around that ... coming frm a 1.7 world.
Guys, remember that this solution is better than all other solutions because it's complexity is on a smaller order. Other solutions AFAIK are on an order of O(n^2) including mine.