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.
Agreed, done
I have fixed the issues, you've mentioned. Judging by the Kata description I figured, I should stick to Option. I added a small test for this.
Thanks for your remarks.
Regarding the C++ solution...
First of all, I don't know who wrote it because it is written as a part of Test Cases section. I rewrote it closely to the original for the test cases, and generalized it myself for the solution. If you think that I should credit the author of the C++ translation, I can do it.
Apparently, it doesn't check for negative values and it uses fixed arrays, knowing, that the tested values will be under 500. I assumed, if it is already aproved, then it must be OK to do it like that as well. Otherwise, these issue also applies to the C++ translation.
This comment is hidden because it contains spoiler information about the solution
Yeah, but why does the task itself requires you to return char*?
I don't understand why C++ solution uses raw pointers and strcmp. Why not std::string?
AFIK asprintf returns an allocated string. Description said that text won't be freed. Therefore memory leak.
The function had a and b passed as const pointers, you shouldn't have changed that. What if the arrays were really const? You should've made copies instead.
If you compare b to a without sorting it would be O(n^2), with sorting it's O(2nlog n + n) = O(n log n) which is better for large arrays.