Posted on

Bracket sequence

()((())((())

Is it correct sequence?

I need just a counter.

foreach char in string {

If next bracket is “(” then inc(counter);

If next bracket is “)” then dec(counter);

If counter < 0 then showmessage(“Error”);

}

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.