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 comment is hidden because it contains spoiler information about the solution
This is a clever solution!
This changes the array as well.
Depends on the size of the array.
Also, even if you had to go through the array twice that's 2n wheras nlogn still takes longer for large n. And in any case 2n is O(n).
I liked it, looks cool for small arrays
uhhhhhhhhh no you can keep track of the 2 greatest numbers visited so far in the array as you loop through lol
You have to go through the whole list and then go back and set the numbers, this isn't efficient.
This is most likely the shortest solution but definitely not optimal.
Sort will take O(nlogn) while a single pass O(n) solution exists.
Sorry, but sorting the array is a performance killer. 44% slower than a single-pass solution.
http://jsperf.com/sort-vs-1-pass
This comment is hidden because it contains spoiler information about the solution
Should add some tests for "Run tests", and details for fail tests.