Ad
  • Custom User Avatar

    There is no test with n that big. So, for the range of the input tested, it is a valid solution.

  • Custom User Avatar

    You've replaced the inner map and join of the above solution with the reduce. 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 a toLowerCase 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.)

  • Custom User Avatar

    Your code is basically the same, why do you say it has less iterations and array operations?