Can someone please tell me what is wrong with this code? (python)


#1

def findMedianSortedArrays(self, A, B):
A=list(A)
B=list(B)
A.extend(B)
A.sort()
if (len(A)==2):
return ((A[0]+A[1])/2)
if (len(A)%2==0):
m=(A[(len(A)-2)/2]+A[len(A)/2])/2
else:
m=A[int(len(A)/2)]
return m

problem with case :
A : [ 0, 23 ]
B : [ ]
Your function returned the following :

11.0

The expected returned value :

11.5

Run as custom input


#2

In python 2
5/2==2 not 2.5
for getting correct division use float(5)/float(2)