Check if it is possible to make two matrices strictly increasing by swapping corresponding values only | Javascript implementation of the above approach ; Function to check whether the matrices can be made strictly increasing with the given operation ; Swap only when a [ i ] [ j ] > b [ i ] [ j ] ; Check if rows are strictly increasing ; Check if columns are strictly increasing ; Driver Code
using System ; using System . Collections ; class GfG { function Check ( a , b , n , m ) { for ( let i = 0 ; i < n ; i ++ ) for ( let j = 0 ; j < m ; j ++ ) if ( a [ i ] [ j ] > b [ i ] [ j ] ) { let temp = a [ i ] [ j ] ; a [ i ] [ j ] = b [ i ] [ j ] ; b [ i ] [ j ] = temp ; } for ( let i = 0 ; i < n ; i ++ ) for ( let j = 0 ; j < m - 1 ; j ++ ) if ( a [ i ] [ j ] >= a [ i ] [ j + 1 ] b [ i ] [ j ] >= b [ i ] [ j + 1 ] ) return " " ; for ( let i = 0 ; i < n - 1 ; i ++ ) for ( let j = 0 ; j < m ; j ++ ) if ( a [ i ] [ j ] >= a [ i + 1 ] [ j ] b [ i ] [ j ] >= b [ i + 1 ] [ j ] ) return " " ; return " " ; } let n = 2 , m = 2 ; let a = [ [ 2 , 10 ] , [ 11 , 5 ] ] ; let b = [ [ 9 , 4 ] , [ 3 , 12 ] ] ; document . write ( Check ( a , b , n , m ) ) ;