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.
Do you need to handle errors? Like if the array has no outliers or more than 1? Or the array is smaller than 3?
going over the "very large array" twice ends up taking twice as long, twice as much memory.
if the array was billions of members long - the 10 lines of code you saved would cost a lost of money.
this code may be impressive to newbies exclusively.
definitely not best practice, you use var, not strict equality operator and filter array twice
This solution is at least 8 years old.
stop using var please, is missleading
Thanks, I just started reading Groking algorithms to be more competent
There is no such thing as 'O(2n)' in big O notation. There are different notations which keeps the constant multiplier before function, such as 'tilde notation', see https://www.reddit.com/r/compsci/comments/1bl0q8/tilde_notation/. But you are right this solution is quite inefficient.
Lol, author says that array can be VERY big, and O(2n) solution gots top place when O(1) solution takes hardly more time to come with)
I'm not saying mine is better, jsut asking a question mate, i'm here to learn.
If we want to argue best practices, where's your validation?
Bruh have you seen yours lol
this is way too inefficient to be in the top solutions, isn't it ?
inefficient! but succinct. but overrated.
I have learned another great lesson about .filter(). Thanks for your solution!
it dont return 0 as output for only 'even' and 'odd' number instead of 0 it return 'first element' for only 'odd' number and 'undefined' for only 'even' number
Loading more items...