If the matrix consists of only 0 ' s ▁ ▁ or ▁ only ▁ 1' s
if ( one . Count == 0 M * N == one . Count ) return - 1 ; for ( int i = 0 ; i < M ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { if ( grid [ i , j ] == 1 ) continue ;