Maximize minimum of array generated by maximums of same indexed elements of two rows of a given Matrix | Python3 program for the above approach ; Function to find the maximum of minimum of array constructed from any two rows of the given matrix ; Initialize global max as INT_MIN ; Iterate through the rows ; Iterate through remaining rows ; Initialize row_min as INT_MAX ; Iterate through the column values of two rows ; Find max of two elements ; Update the row_min ; Update the global_max ; Print the global max ; Driver Code ; Given matrix mat [ ] [ ] ; Given number of rows and columns ; Function Call
import sys NEW_LINE def getMaximum ( N , M , mat ) : NEW_LINE INDENT global_max = - 1 * ( sys . maxsize ) NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT row_min = sys . maxsize NEW_LINE for k in range ( 0 , M ) : NEW_LINE INDENT m = max ( mat [ i ] [ k ] , mat [ j ] [ k ] ) NEW_LINE row_min = min ( row_min , m ) NEW_LINE DEDENT global_max = max ( global_max , row_min ) NEW_LINE DEDENT DEDENT return global_max NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT mat = [ [ 5 , 0 , 3 , 1 , 2 ] , [ 1 , 8 , 9 , 1 , 3 ] , [ 1 , 2 , 3 , 4 , 5 ] , [ 9 , 1 , 0 , 3 , 7 ] , [ 2 , 3 , 0 , 6 , 3 ] , [ 6 , 4 , 1 , 7 , 0 ] ] NEW_LINE N = 6 NEW_LINE M = 5 NEW_LINE print ( getMaximum ( N , M , mat ) ) NEW_LINE DEDENT