#2 most askedVery commonEasyStack
Valid Parentheses
New to Stack? Learn it from scratch firstTwo Pointers & Stacks β
π’ Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.Given a string of brackets ()[]{}, return True if every opening bracket is closed by the same type, in the right order.
"([]{})" β True, "(]" β False, "((" β False.
π§ͺ Practice
Write your solution, then press Run tests. Explain your approach out loud as you go.
def is_valid(s):
pass
Output appears here. Press Run or Ctrl/β + Enter.
Try it first. Struggling for a few minutes is how it sticks.