StackString
Given a string made only of the characters ( ) [ ] { }, decide whether it is valid. A string is valid when every opening bracket is closed by the same type of bracket, and brackets are closed in the correct order.
Input
A single line containing the bracket string.
Output
Print true if the string is valid, otherwise print false.
Constraints
1 <= length <= 10^4
Example 1
Input
()
Output
true
One pair, correctly closed.
Example 2
Input
()[]{}
Output
true
Three pairs, each closed in order.
Example 3
Input
(]
Output
false
( is closed by ], which is the wrong type.