Skip to content

Comment on A Brutal Look at Balanced Parentheses, Computing Machines, and Pushdown Automataparent

Comments

Yes. Actually, a more interesting example which does not complicate the statement (not the problem) too much is to check for nested parenthesis and brackets:

(([[()])) -> ok ((([](])) -> not ok

Hope OP gets this message.

In case anybody is interested, when we generalize the concept we're talking about Dyck languages.

https://en.wikipedia.org/wiki/Dyck_language

I was surprised to not see a connection made to free groups in the article.

EDIT: The wikipedia article that is.

Your solution incorrectly fails ({}). You need the stack.

You're right ... no counter can tell the difference between ({ and {(. Oops.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.