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.
Is not tail rec (can go on stackoverflow) and moreover Java does not support tail rec optimization.
If you really want to go with rec mode you should use an accumulator.
I don't get it yet, but I find it sexy.
According to the specification you don’t have to check array is null or lenght= 0
The problem of this code is big integers. When one uses them, the code works for too long and we get java.lang.OutOfMemoryError. When one uses for example Integer.MAX_VALUE/10, we already get java.lang.OutOfMemoryError, not to mention Integer.MAX_VALUE.
This comment is hidden because it contains spoiler information about the solution
nice one :)
This contains untested code. Since arr will never be null and has at least 1 element, the return inf[0] is never tested.
And i like the use of the IntStream.
Doesn't work for negative input!