For the last row , note that the last column is not taken into consideration as the bottom right element has already been considered in the last column previously
for ( int j = 0 ; j < N - 1 ; j ++ ) { if ( row [ N - 1 ] [ j ] ) cnt ++ ; } return cnt ; }