Calculate sum between current left and right for every row ' i ' , consider '0' as '-1
' NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if mat [ i ] [ right ] == 0 : NEW_LINE temp [ i ] -= 1 NEW_LINE else : NEW_LINE temp [ i ] += 1 NEW_LINE DEDENT DEDENT