Check if the given matrix is increasing row and column wise | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; #define N  2 NEW_LINE #define M  2 NEW_LINE bool isMatrixInc ( int a [ N ] [ M ] ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( i - 1 >= 0 ) { if ( a [ i ] [ j ] <= a [ i - 1 ] [ j ] ) return false ; } if ( j - 1 >= 0 ) { if ( a [ i ] [ j ] <= a [ i ] [ j - 1 ] ) return false ; } } } return true ; } int main ( ) { int a [ N ] [ M ] = { { 2 , 10 } , { 11 , 20 } } ; if ( isMatrixInc ( a ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }