Check if the given matrix is increasing row and column wise | Python3 implementation of the approach ; Function that returns true if the matrix is strictly increasing ; Check if the matrix is strictly increasing ; Out of bound condition ; Out of bound condition ; Driver code
N , M = 2 , 2 NEW_LINE def isMatrixInc ( a ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT for j in range ( M ) : NEW_LINE INDENT if ( i - 1 >= 0 ) : NEW_LINE INDENT if ( a [ i ] [ j ] <= a [ i - 1 ] [ j ] ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT DEDENT if ( j - 1 >= 0 ) : NEW_LINE INDENT if ( a [ i ] [ j ] <= a [ i ] [ j - 1 ] ) : NEW_LINE INDENT return False ; NEW_LINE DEDENT DEDENT DEDENT DEDENT return True ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT a = [ [ 2 , 10 ] , [ 11 , 20 ] ] ; NEW_LINE if ( isMatrixInc ( a ) ) : NEW_LINE INDENT print ( " Yes " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) ; NEW_LINE DEDENT DEDENT