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.
good
Nice
Ok sooo for task with Large array what is the type of Sort you advises ?
The sorting approach is generally less efficient for this specific task, especially when dealing with large arrays, due to the higher time complexity of the sorting algorithm. The looping approach focuses on finding only the two smallest numbers, resulting in better performance for this particular requirement.
how dose the code runs? your code gives me sort is not a function 😕
This comment is hidden because it contains spoiler information about the solution
what is the point in storing the result of running sort method on the array if it's an 'in-place' algorithm?
He did not do the same thing. The .sort() method has a time complexity of O(n log(n)). This algo can be solved with one simple for loop as seblm described with a time complexity of O(n), which will be far more performant as your array grows in size.
ofcourse its a performance killer, but we try to be smart here by providing a solution with less lines possible.
mine is just fine smaller and confined
whats the difference than? you did the same thing.
What else you want me to do?
Damn, balu9 has no chill (⊙_⊙;)
Thank you for the answer!
in js, sort by itself works by comparing strings, so the use of
a - b
coerces those two values into a number (less than zero, zero, or greater than zero)Loading more items...