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.
no way the solution was just brute forcing it, it makes sense though cause you only swap near the beginning
If you ain't using 3 loops, you ain't trying!
niubi, clear boy
Whenever possible, use switch is the best practice. Firstly, readability, and secondly, switch works more efficiently than if - else chains, since with if else the performer does not know in advance which condition will suit him, everything is calculated in runtime, but when using switch, the performer almost instantly chooses what came up according to the condition :) Good luck in your studies!
Sometimes the answer is right in front of you... Looking at this makes me feel a bit silly about my solution :D
Why int timeouts but long doesn't though?
Good point, there is no necessity to iterate twice to collect the target data.
And could be done with streams API using class IntSummaryStatistics, which fetches count, min, max, and average from a stream in one go.
Brilliant!
My solution was very memory inefficient. This is great!
Simple and deep. Very tricky code!
Looks cute, but processing whole list two times instead of just once?
Your
filterS
results in StackOverflowError for Streams with rare satisfying elements, e.g. inNice
primeS()
, although somewhat slow. Try, for example, this:This comment is hidden because it contains spoiler information about the solution
Frankly, I don't like this solution.
It is not readable, and logic is quite complex for no apparent reason.
Compare with my solution to see what I mean
maybe "Math.pow(root, i) == n" should be repalced by "(Math.pow(root, i) - n) < delta".
indeed. it fails to respect the previous constraints for following characters in the chain when correcting cIndex with pIndex.
Loading more items...