Check if the given matrix is increasing row and column wise | Java 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
import java . io . * ; class GFG { static int N = 2 ; static int M = 2 ; static boolean isMatrixInc ( int a [ ] [ ] ) { 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 ; } public static void main ( String [ ] args ) { int a [ ] [ ] = { { 2 , 10 } , { 11 , 20 } } ; if ( isMatrixInc ( a ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }