Valid Parentheses
Easy
Stacks
Stack
String
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
Constraints
1 ≤ s.length ≤ 10^4
Examples
Example 1:
Input: ()
Output: true
Example 2:
Input: ()[]{}
Output: true
Example 3:
Input: (]
Output: false
Hints
Use a stack. Push opening brackets, pop on closing.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console