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.
O(2n) ~ O(n) :D :D :D
I assume ImmePak meant that the function iterates through the array twice: once to find the minimum, and again to find the maximum. Thinking about performance, it's theoretically unnecessary and somewhat inefficient to do that. (I don't know whether V8 optimizes it away; I assume not).
However, I find this solution simple and easy to read. If this function would be called infrequently and on small arrays, it would waste only an insignificant amount of time.
What do you mean by "array double check"?
but in the and this kata is more about pure mathematic, and less about algorithms. You can be super-bruse-lee-algorithm master, but if tou don't know math solution of this - all your attempts will fail.
Yeah, you are totally right. I've found a problem with big n.
Its probably because your code is not optimised enough.
The 3 pre-set tests each use very small numbers for n however the actual tests that get run when you submit use much larger numbers for n.
The issue then is that if your code takes too long for the cdewars server it will time out.
Test your code in a local environment and see how long it takes, if it takes longer than codewars allows before timing out then you will have to change your approach to one that takes les time.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
It seems that nowadays new programmers almost forgot that performance is a valuable feature of every code.
Hello @ImmePak, I'm sorry, I didn't understand the question, could you detail?
People, are you serious?
Top ranked solution with array double check????
I can't understand why people consider this like a best solution.
String is handled twice (!!)
Possible two extra steps?
Too bad performance, you should consider situation when your array is big.
Should do all operation in ONE cycle-run