If the matrix consists of only 0 ' s ▁ ▁ or ▁ only ▁ 1' s
INDENT if ( one == [ ] or M * N == len ( one ) ) : NEW_LINE INDENT return - 1 NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE if ( grid [ i ] [ j ] == 1 ) : NEW_LINE INDENT continue NEW_LINE DEDENT DEDENT DEDENT