Valid Parentheses
Easy
Stack
String
Parentheses

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets, and open brackets must be closed in the correct order.

Examples:

Input:"()"
Output:true
Input:"()[]{}"
Output:true
Input:"(]"
Output:false

Constraints:

  • 1 ≤ s.length ≤ 10⁴
  • s consists of parentheses only '()[]{}'.
Code Editor
Loading advanced editor...
Console Output

Ready to execute

Click "Run Code" to see your output here