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.
you're a genius brother
So much to learn and this kind of solutions just make me want to lear more
sorting is O(nlogn) and summaryStatistics is O(n) (i think), so sorting is a lot slower for larger arrays
I dont know if this is still relevant but: stream(numbers.split(" ")) - this part splits String to array of strings dividing each by " " - so you will have as an output String[] of numbers (in our case), and then this array will get converted to stream, .mapToInt(Integer::parseInt) maps every string element of stream - one by one - to int: you may write this as: mapToInt(str -> Integer.parseInt(str)). .summaryStatistics() converts to IntSummaryStatistics object which stores some values related to collection as: count, sum, max and min - it is asigned to stats (var works as an auto in c++ - joker that is evaluated based on return value of right side in this case is just IntSummaryStatistics). Then in return we call getMin and getMax which is self explanatory - it is casted to String because we are adding also " " which is indication that this should be treated as String.
I considered using it but in the end, sticked to sorting - does anyone know how summaryStatistics compares to sorting performance wise
me neither, since 1.8 ...