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.
This comment is hidden because it contains spoiler information about the solution
Why not use recursion?
I just thought that this is what was really missing here: Some more test cases, to make sure that it really works as expected.
Interestingly enough, the tests for the edge cases reveal how the current solution differs from the original implementation, which is the way how negative as well as very large input resulting in overflow is handled. While the current implementation throws a
NumberFormatException
in those cases, the original version of the algorithm would not throw at all and instead produce the following results:You can use reverse method on StringBuffer.
Is there a better way to do it?
This comment is hidden because it contains spoiler information about the solution