Ad
  • Custom User Avatar

    So your code fails when there is an odd number of the same letter.

  • Custom User Avatar

    There are already tests with "a" and "aa" as input (at least in Python and Javascript). Which language are you talking about?

  • Custom User Avatar

    Thenks for finding an edge case Mincer!

    Sadly, at this point such a change might invalidate a good number of solutions, and I'm not familiar with the process involved there for CodeWars.

    The tests also do not have random list tests, and do not protect from user manipulation of the data sets.

    As this problem is now a little over 6 years-old, I'm inclined to leave it as-is. Particularly, due to the fact that as a method to teach people about the power of limiting array traversals and the usefulness of hashmaps, it still fulfills that need.

  • Default User Avatar

    Hm, re-check your solution again. Universal solution can handle datasets like this....

  • Custom User Avatar

    Great tip -- really pushed me over the edge. Math the solution not code.

  • Custom User Avatar

    I had solved the test with loops but timed out. Saw your tip and A HA! I solved the tests with a totally new approach (no loops) but it still times out. Grrr EDIT: Another commenter here mentioned sorting the arrays itself will cause a timeout. Although I did remove the for loops I had left the code to sort the array even though it wasn't necessary anymore. Problem solved.

  • Custom User Avatar

    thanks for the tip. ended up solving it without any loops