Pick the maximum distance of fresh orange to some rotten orange
for i in range ( R ) : NEW_LINE INDENT for j in range ( C ) : NEW_LINE INDENT if ( arr [ i ] [ j ] == 1 and table [ i ] [ j ] > max ) : NEW_LINE INDENT max = table [ i ] [ j ] NEW_LINE DEDENT DEDENT DEDENT