Make N pairs from Array as ( X , Y ) coordinate point that are enclosed inside a minimum area rectangle | Function to make N pairs of coordinates such that they are enclosed in a minimum area rectangle with sides parallel to the X and Y axes ; A variable to store the answer ; For the case where the maximum and minimum are in different partitions ; For the case where the maximum and minimum are in the same partition ; Return the answer ; Driver code ; Given Input ; Function call
def minimumRectangleArea ( A , N ) : NEW_LINE INDENT ans = 0 NEW_LINE A . sort ( ) NEW_LINE ans = ( A [ N - 1 ] - A [ 0 ] ) * ( A [ 2 * N - 1 ] - A [ N ] ) NEW_LINE for i in range ( 1 , N , 1 ) : NEW_LINE INDENT ans = min ( ans , ( A [ 2 * N - 1 ] - A [ 0 ] ) * ( A [ i + N - 1 ] - A [ i ] ) ) NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT A = [ 2 , 4 , 1 , 5 , 3 , 6 , 7 , 8 ] NEW_LINE N = len ( A ) NEW_LINE N //= 2 NEW_LINE print ( minimumRectangleArea ( A , N ) ) NEW_LINE DEDENT