loading…
Write is_valid(s) for a string of ()[]{}. It is valid when every opener is closed by the same type, in the right order.
is_valid("()[]{}") -> True
is_valid("(]") -> False
is_valid("([)]") -> False
Stuck on the idea itself? The stack lesson walks through the pattern from scratch.