I am practicing in an automatic judge for algorithm in one of the carreer sites and I have the following question.
In one of the puzzles the question is to find the median of 2 sorted arrays and the signature of the method to implement is:
public double findMedianSortedArrays(int A[], int B[])
I written the code and some of the tests failed.
Looking at the results though the failures reported are as follows:
Input Output Expected
[], [1] 1.0 1
[2], [] 2.0 2
It seems I am rusty on the fundamentals.
My question: How can it expect an 1 or 2 and reject 1.0 if the method returns a
double?
My snippet of code on the calculation of merge is:
if(array.length %2 == 0){
return (array[middle] + array[middle - 1])/(double)2;
}
else{
return (double)array[middle];
}

It’s an error in the judge. If I go to the site, select ‘Java’ and fill in the following Java implementation (just filling in one line, the
return 0;:the report states
output: 0.0for all cases.The C++ equivalent does not seem to suffer from the same problem. If I fill in this:
then the report states
output: 0for all cases.