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.
I don't think that my c++ solution uses any (advanced) math skills.
It only uses one optimization that you must have seen (and probably used) in previous katas on level 6.
It's a bit of a brute force solution, since it does not use the related theorems, but all tests did pass.
If I look at Firefly2002's solution, I like it much more than the one of mine, but I'm not sure that it has a lower O() complexity thand the one of mine (but it can be much faster for the simple cases).
But, reading further down in this discussion, I see that slower language might have a harder time finishing the task fast enough... so you might be right.
With this solution, I've tried to avoid the creation of a temporary string. In most cases, the string will not even be resized. By first putting the character in a temporary char and removing it from the string, I could have avoided any resize... I guess.