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, not significantly. Unless you can make the asymptotic complexity better than
O(n²)
, it's not going to be significant, it's ging to be a micro-optimisation.what about var j = i + 1, for comparing with itself is not necessary
I like this. LOL! The solution with the highest "best practices" rating, and people talking about how inefficient it is. Of course, you're all right. It's pretty though, and gets the job done. :)
Have a look at this one for comparison... http://www.codewars.com/kata/reviews/525099441625e506d500044e/groups/55aa3eaaa85fdbbedf0000a0
Also I suggest you break the inner loop when you find
j-i > result
, since calculating cycles more would be wasteful.That's a good point. It would still be a O(n^2) algorithm but it would cut out about half the checks.