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.
It's all good, we understand your feelings.
And isn't the answer to your question in the explanation after you passed the kata?
You have a problem there with the global var, when calling the function several times, it'll keep the previous value. Even then, recursion is not a good approach for this problem, because the input values are very large and it'll overflow the stack.
Go ahead, I'll try to answer it without giving out the solution.
map
andreduce
are two loop-alike methods, so your solution isn't O(n).