algorythms
Stack
LC #20Easy

Valid Parentheses

Stack

Problem

Given a string containing just (, ), {, }, [ and ], determine if the input string is valid.

stringstack

Constraints

  • 1 ≤ s.length ≤ 10⁴
  • s consists of parentheses only ().

Example

Inputs = "()[]{}"
Outputtrue
Why

All brackets are closed in the correct order by the same type of brackets.

Hints — reveal one at a time