Valid Parentheses

Easy

Topics
StringStack

Given a string s containing just ()[]{}, determine if the input is valid: brackets are closed by the same type in the correct order.

Example 1

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

Example 2

Input:  s = "([)]"
Output: false

Constraints

  • 1 <= s.length <= 10^4
  • s consists of brackets only.
Run ⌘' · Submit ⌘⏎