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 why i didnt think this way
first i filtered the array in map function thn reduced it
geniusly...
Wow.
They're not nested.
It's the difference between multiplication and addition.
Would that not be O(n^2) because you iterate over the array with two different loops -- the reduce() and the .map()?
*Oops. Leaving the question up but I realized my mistake after.
Have you looked at my solution? It's
O(n)
. Just clickView Solution
.Or look at the second most upvoted solution. It's
O(n)
.What's the O(n) solution?
Sigh ..
(
O(n^2)
time whereO(n)
is possible )It has been said, "The blues live in the notes you don't play"
Remember not only to say the right thing in the right place, but far more difficult still, to leave unsaid the wrong thing at the tempting moment.
Don't say much, do ya? ;)