You will be given a sequence of opening and closing brackets of different types ((
, )
, [
, ]
, {
, and }
). You will have to determine if the sequence is a valid one.
A sequence of brackets is considered valid if every opened bracket of a type has a closing bracket of an equivalent type appearing after it. And, there are no unpaired brackets in the sequence.
The input will contain a string of opening and closing brackets. The string will be no longer than 25 characters.
Print if the input string contains a valid sequence of parentheses. Otherwise, print .
Input | Output |
---|---|
[[(){]}] | No |
Input | Output |
---|---|
(([]{}[{}]){})[] | Yes |