Function to find the lexicographically next balanced bracket expression if possible
def next_balanced_sequence ( s ) : NEW_LINE INDENT next = " - 1" ; NEW_LINE length = len ( s ) ; NEW_LINE depth = 0 ; NEW_LINE for i in range ( length - 1 , - 1 , - 1 ) : NEW_LINE DEDENT