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
def minimiseMedian ( arr , n ) : NEW_LINE INDENT arr . sort ( ) ; NEW_LINE ans = abs ( arr [ n // 2 ] - arr [ ( n // 2 ) - 1 ] ) ; NEW_LINE return ans ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ 15 , 25 , 35 , 50 ] ; NEW_LINE n = len ( arr ) ; NEW_LINE print ( minimiseMedian ( arr , n ) ) ; NEW_LINE DEDENT