Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think that '()))((' will be judged balanced by the above code.


No, he checks each time through the loop to see if the counter ever goes below zero; if it does, then the string is unbalanced.


Why don't you write a unit test and see? :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: