Final array which will store the arranged string
zz = [ 0 ] * len ( s ) NEW_LINE for i in range ( len ( a ) - 1 ) : NEW_LINE INDENT if ( a [ i ] > 0 ) : NEW_LINE INDENT if ( cc > 0 ) : NEW_LINE INDENT zz [ i ] = 1 NEW_LINE cc -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if ( cc == 0 ) : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT