#C2111. Valid Parenthesis Expression
Valid Parenthesis Expression
Valid Parenthesis Expression
Given a string s consisting of characters (')
, ('{'
, ('['
and their corresponding closing brackets, determine if the input string is a valid parenthesis expression.
An expression is considered valid if:
- Every opening bracket has a corresponding closing bracket of the same type.
- Brackets are closed in the correct order.
- An empty string is also considered valid.
For example, the mapping is given by \(\{')':'(', ']':'[', '}':'{'\}\). Use this mapping to validate the expression.
inputFormat
The input is provided via standard input (stdin) as a single line containing the string s with no spaces. The string only consists of the characters '(', ')', '{', '}', '[' and ']'.
outputFormat
Output via standard output (stdout) a single line with either "True" if the string is a valid parenthesis expression, or "False" if it is not valid.
## sample()[]{}
True