Hacker News new | ask | show | jobs
by abustamam 3767 days ago
wouldn't that just see if there are an equal amount of parentheses, not whether or not they're balanced?

For example, your code would return true for ")())((" even though nothing is balanced. I was thinking more of a stack; push to stack only on opens, pop on closes, if we get a close before an open is on the stack, then we return false.

But I only thought about it for a few minutes so it's rather rudimentary.