Problems/

Valid Parentheses

easy

Given a string s containing only the characters (, ), {, }, [ and ], determine whether the brackets are valid:

  1. Every opening bracket is closed by the same type of bracket.
  2. Brackets close in the correct order (most recently opened, first closed).
  3. Every closing bracket has a matching opening bracket.

Example 1

Input: s = "()[]{}"
Output: true

Example 2

Input: s = "(]"
Output: false

Example 3

Input: s = "([{}])"
Output: true

Constraints

  • 1 <= s.length <= 10000

Input

s = "()[]{}"

Expected

true

6 hidden tests run on submit