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.
Cool same as mine... but I typed the return value better
This is best algo I saw so far with O(n) time complexity.
Because of lack of testing cases in this kata, you did not spot the mistake in your code. There is 1 missing part in this code.
Try your function with a simple argument [1, 2], check what happens then...
This solution is "brute force".
it has a time complexity of O(n log n)
https://stackoverflow.com/questions/57763205/what-is-array-prototype-sort-time-complexity
I solved this kata with O(n), I was surprised to find this one as most upvoted solution.
I was looking for even better solutions than mine.