Python3 program to find the maximum distance from a 0 - cell to a 1 - cell
def maxDistance ( grid ) : NEW_LINE INDENT one = [ ] NEW_LINE M = len ( grid ) NEW_LINE N = len ( grid [ 0 ] ) NEW_LINE ans = - 1 NEW_LINE for i in range ( M ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE if ( grid [ i ] [ j ] == 1 ) : NEW_LINE INDENT one . append ( [ i , j ] ) NEW_LINE DEDENT DEDENT DEDENT