If 0 then start new cumulative one from that i
else : NEW_LINE INDENT left [ i ] = 0 NEW_LINE DEDENT for i in range ( n - 2 , - 1 , - 1 ) : NEW_LINE if ( s [ i ] == '1' ) : NEW_LINE INDENT right [ i ] = right [ i + 1 ] + 1 NEW_LINE DEDENT else : NEW_LINE INDENT right [ i ] = 0 NEW_LINE DEDENT for i in range ( 1 , n - 1 ) : NEW_LINE