517. Validate Door Lock
0
Medium
Mayank is standing outside the office of Coding Blocks. In order to enter the office, he needs to choose a valid string of parentheses. Given a string str that contains only the characters '(', ')', '{', '}', '[', and ']', help Mayank select a valid input string.
A string is considered valid if:
1. Open brackets are closed by the same type of brackets.
2. Open brackets are closed in the correct order.
3. Every closing bracket has a corresponding opening bracket of the same type.
A string is considered valid if:
1. Open brackets are closed by the same type of brackets.
2. Open brackets are closed in the correct order.
3. Every closing bracket has a corresponding opening bracket of the same type.
Input Format
You will be given a string.
Output Format
Print 'true' if the string is valid, and 'false' if it is not.
Example
Input
()
Output
true
Constraints
1 <= s.length <= 104
S consists of parentheses only '()[]{}'
S consists of parentheses only '()[]{}'
Loading...
View Submissions
Console