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.
?? LOL
Doesn't work. Fatal flaw. Otherwise good solution.
This comment is hidden because it contains spoiler information about the solution
Will fail if array[0] == array[1] and the array is sorted ascending (array[i]<=array[i+1]).
Otherwise good solution.
I've added a small fix, random array will now always be of odd length.
As the great Justin Bieber said - Sorry!
Thanks for the feedback!
In C variant I was still getting even-length arrays, so I decided to handle that and compute median as it should be computed -- mean of 2 middle elements.
So I spent few hours after that trying to figure out error, then I decided to handle even-length arrays as odd-length, and all tests passed.
You should either fix description and tests, or just fix tests to generate only odd-length arrays.
The most simple thing you should do is add
while
loop inint getRandomInteger(int lowerBoundInclusive, int upperBoundExclusive)
, checking for even value.P.S. Didn't mark this as spoiler since kata for C is broken and people can actually spend quite a lot time figuring out problem that doesn't exist.