Partition the array into two odd length groups with minimized absolute difference between their median | Function to find minimise the median between partition array ; Sort the given array arr [ ] ; Return the difference of two middle element of the arr [ ] ; Driver Code ; Size of arr [ ] ; Function that returns the minimum the absolute difference between median of partition array
function minimiseMedian ( arr , n ) { arr . sort ( ( a , b ) => a - b ) ; return Math . abs ( arr [ n / 2 ] - arr [ ( n / 2 ) - 1 ] ) ; } let arr = [ 15 , 25 , 35 , 50 ] ; let n = arr . length ; document . write ( minimiseMedian ( arr , n ) ) ;