Valid Parentheses
Easy
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid when every opening bracket is closed by the same type of bracket and brackets are closed in the correct order.
Examples:
Example 1:
Input:"()"
Output:true
Explanation:The pair of parentheses is correctly closed.
Example 2:
Input:"()[]{}"
Output:true
Example 3:
Input:"(]"
Output:false
Constraints:
- 1 <= s.length <= 10^4
- s consists only of parentheses, brackets, and braces
Limits:
Time limit: 1000 ms
Memory limit: 128 MB
Topics
Stack
Loading editor...
▶
Run your code to test against examples