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.
There is no test with n that big. So, for the range of the input tested, it is a valid solution.
You've replaced the inner
map
andjoin
of the above solution with thereduce
. While this will reduce the number of times the string has to effectively be referenced (albeit in a roundabout way), it loses that benefit by having to perform a hell of a lot more string concatenations. Ultimately, I imagine your solution would be (much) less performant than the above solution. (Also, you don't have atoLowerCase
on the string in the third bit of the ternary, so your solution will fail if the input string has upper case letters in odd-numbered positions.)Your code is basically the same, why do you say it has less iterations and array operations?