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.
So your code fails when there is an odd number of the same letter.
There are already tests with
"a"
and"aa"
as input (at least in Python and Javascript). Which language are you talking about?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.
Hm, re-check your solution again. Universal solution can handle datasets like this....
Great tip -- really pushed me over the edge. Math the solution not code.
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.
thanks for the tip. ended up solving it without any loops