Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Matching Brackets

Limits 1s, 512 MB

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.

Input

The input will contain a string of opening and closing brackets. The string will be no longer than 25 characters.

Output

Print $\texttt{Yes}$ if the input string contains a valid sequence of parentheses. Otherwise, print $\texttt{No}$.

Samples

InputOutput
[[(){]}]
No
InputOutput
(([]{}[{}]){})[]
Yes

Discussion

Statistics


92% Solution Ratio

md_jakariyaEarliest, 9M ago

md_jakariyaFastest, 0.0s

JUNIORHMMC_CODLightest, 0 B

hredhayxzShortest, 146B

Submit

Login to submit