← 返回 amazon 的题目列表Valid Parentheses
类型:online_judge
Given a string s containing only the characters '(', ')', '{', '}', '[', and ']', determine whether the parentheses are valid.
A valid string must satisfy:
Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Every closing bracket must have a corresponding opening bracket.
Input Format
A single line containing string s.
Output Format
Print true if the string is valid; otherwise print false.
Constraints
0 <= len(s) <= 10^5
s contains only ()[]{}.
Example
Input:
()[]{}
Output:
true
Example
Input
()
Output
true