Function to check if all elements present in descending diagonal starting from position ( i , j ) in the matrix are all same or not
bool checkDiagonal ( int mat [ N ] [ M ] , int i , int j ) { int res = mat [ i ] [ j ] ; while ( ++ i < N && ++ j < M ) {