#C7920. Valid Parentheses Checker
Valid Parentheses Checker
Valid Parentheses Checker
Given a string containing only the characters ( ( ), {, }, [ and ]), write a program to determine if the string is a valid sequence of brackets. A valid sequence must satisfy the following conditions:
- Every opening bracket has a corresponding closing bracket of the same type.
- Brackets must be closed in the correct order.
For example, the string
()[] {}
is valid, while the string ([)]
is not.
inputFormat
The input consists of a single line containing a string (s). The string (s) may be empty and will consist solely of the characters: (
, )
, {
, }
, [
and ]
.
outputFormat
Output a single line: print True
if the string is a valid sequence; otherwise, print False
.## sample
()[]{}
True