Valid Parentheses

Implement isValid

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is validValidEvery opening bracket is closed by the same type of bracket, and brackets are closed in the correct order — the most recently opened bracket must be closed first.. A string passes this check when three things hold at once: each closing bracket matches the type of the bracket it's paired with, brackets close in the right nesting order (innermost first), and no closing bracket ever shows up without a matching opener already waiting for it.

Example 1:

Input: s = "[]"

Output: true

Example 2:

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

Output: true

Example 3:

Input: s = "[)"

Output: false

+ 8 hidden test cases run on Submit.

Constraints:

  • 1 ≤ s.length ≤ 10⁴
  • s consists only of the characters '(', ')', '{', '}', '[' and ']'

s =

[]