Valid Parentheses
Easy
Stack
Time Limit: 1000ms
Memory Limit: 128MB
Problem Description
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.
- Open brackets must be closed in the correct order.
- Every close bracket has a corresponding open bracket of the same type.
Constraints
- 1 <= s.length <= 10^4
- s consists only of parentheses characters: ()[]{}
Input
{"s": "()[]{}"}
Output
true
Loading...
Available Test Cases:10 test cases
Test Case 1Sample
Input:
{"s": "()[]{}"}
Expected Output:
true
Test Case 2Sample
Input:
{"s": "(]"}
Expected Output:
false
Test Case 3Sample
Input:
{"s": "([{}])"}
Expected Output:
true
Test Case 4Sample
Input:
{"s": "((("}
Expected Output:
false
Test Case 5Sample
Input:
{"s": "()"}
Expected Output:
true
Test Case 6Sample
Input:
{"s": "([)]"}
Expected Output:
false
Test Case 7Sample
Input:
{"s": "{[]}"}
Expected Output:
true
Test Case 8Sample
Input:
{"s": ""}
Expected Output:
true
⚠️ Hidden test case
Test Case 9Sample
Input:
{"s": "(((())))"}
Expected Output:
true
⚠️ Hidden test case
Test Case 10Sample
Input:
{"s": "}{"}
Expected Output:
false
⚠️ Hidden test case