Maximize minimum of array generated by maximums of same indexed elements of two rows of a given Matrix | C # 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
using System ; class GFG { static int getMaximum ( int N , int M , int [ , ] mat ) { int global_max = int . MinValue ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { int row_min = int . MaxValue ; for ( int k = 0 ; k < M ; k ++ ) { int m = Math . Max ( mat [ i , k ] , mat [ j , k ] ) ; row_min = Math . Min ( row_min , m ) ; } global_max = Math . Max ( global_max , row_min ) ; } } return global_max ; } public static void Main ( ) { int [ , ] 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 } } ; int N = 6 , M = 5 ; Console . WriteLine ( getMaximum ( N , M , mat ) ) ; } }