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
This comment is hidden because it contains spoiler information about the solution
Finding out the syntax to get the return statement to work was difficult. Other than that it was a good kata. IF you could smooth out the syntax of the return statements I think it would make it an overall better kata. (Javascript)
There are issues with some of the submission test cases. For example the fourth one has these two numbers listed as the price, and discount. However, the Math.round() cannot be used because of the next test case. Either make your test cases more exact or make sure the numbers always come out to nice whole numbers.
373.85 11.2
Expected: 421, instead got: 421.0022522522523
i really dont know how to help with that. Any suggestions??
Loading more items...