Valid Parentheses Extended
Medium
Strings
Stack
Given a string containing '(', ')', '{', '}', '[', ']', determine if the input string is valid. Extended: also handle nested structures.
Output: true or false
Constraints
1 <= s.length <= 10000
Examples
Example 1:
Input: ()[]{}
Output:
Example 2:
Input: (]
Output:
Hints
Use a stack.
Push opening brackets, pop for closing.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console