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.
lol i tried this and didnt work
it does more than twice. 2n times
Nice :| Check my code. I use reduce once and a single loop without much variables
i believe performance is always the main concern; it isnt about looking cool and getting it in one line; that is clever yes but not best practice; best practice means most efficient and clear and scalable (which means if you want to add or remove a aspect of the code you dont have to rework on all aspects of the code only the aspect you want to) ALWAYS!!!!
This solution doesn't even pass all the tests.
it does not work with [5,0,0,0,0], [0,0,0,0,5] and [20,10,-80,10,10,15,35]
your result -1 -1 -1
should beat the result 0 4 0
because
Last one:
You are given the array {20,10,-80,10,10,15,35}
At index 0 the left side is {}
The right side is {10,-80,10,10,15,35}
They both are equal to 0 when added. (Empty arrays are equal to 0 in this problem)
Index 0 is the place where the left side and right side are equal.
What this simbol means matte?
O(n^2)
I was wondering about this.. the problem describes this corner case but doesnt test for it when you submit? This code doesnt appear to handle that case.
It does reduce and slice twice, but it's possible to do both only once.
Never before has a comment been so correct. lol.
What qualifies as "best practice" depends on the context. When performance is a concern, yes, an O(n) solution is best practice. When performance is not a concern, clarity and maintainability is best practice. Performance is generally not a concern when the potential number of items results in little or no discernable delay in processing. To be fair, though, I find this solution to be neither fastest nor clearest. I think what the author was going for was "most succinct."
This comment is hidden because it contains spoiler information about the solution
I noticed it too
My test of this example showed that the results do not agree. It is not clear how they made such a decision.
Saw this in the recent comments, now I see what all the hooplah is about, lol.
Please solve this linear before you call it best practice...
Loading more items...