FreeCareerPath
Build the PrimitiveEasy

Valid Parentheses

Write `is_valid(s)` returning `True` when every bracket in the string closes in the right order. The string contains only `()[]{}`. is_valid("()[]{}") -> True is_valid("(]") -> False is_valid("([)]") -> False Push openers, and on a closer check that the top of the stack is its partner. Two endings people forget: a closer arriving on an empty stack, and openers still on the stack when the string runs out.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Valid Parentheses" are saved to your account — logging in takes a few seconds.

Valid Parentheses — FreeCareerPath