← 返回 oracle 的题目列表Validate Parentheses String
类型:online_judge
Problem
Given a string s containing only '(', ')', '{', '}', '[', ']', determine if the input string is valid.
A string is valid if:
Open brackets are closed by the same type of brackets.
Open brackets are closed in the correct order.
Every closing bracket has a corresponding opening bracket.
Input
A single line string s.
Output
Print true or false.
Constraints
1 <= len(s) <= 1e5
Examples
Input: () -> Output: true
Input: ()[]{}' -> Output: true
Input: (] -> Output: false
Input: ([)] -> Output: false
Input: {[]} -> Output: true
Example
Input
()
Output
true