Valid Parentheses

Easy
string stack
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.

Input Format
A string s
Output Format
true or false
Constraints
1 <= s.length <= 10^4
s consists of parentheses only "()[]{}"
Sample Input/Output
Input:
()[]{}
Output:
true
Explanation

All brackets are properly matched and closed.

Solution Hints
120
Points
2000ms
Time Limit
256MB
Memory Limit
Code Editor
Register to Submit
Register to Access Code Editor

Create a free account to solve coding problems and track your progress.

Register Now
Feedback