#K52117. Valid Parentheses

    ID: 29239 Type: Default 1000ms 256MiB

Valid Parentheses

Valid Parentheses

You are given a string s consisting of characters including '(', ')', '{', '}', '[' and ']'. Your task is to determine if the input string is a valid parentheses sequence.

A string is considered valid if:

  • Open brackets must be closed by the same type of brackets.
  • Open brackets must be closed in the correct order.

The solution should read input from standard input (stdin) and write the result to standard output (stdout). The output should be either True or False depending on whether the string is valid or not.

In other words, given a string s, determine if it is valid. The condition can be mathematically represented using LaTeX as:

\( \text{isValid}(s) = \begin{cases} \text{True} & \text{if } \forall \, c \in \{ '(', '{', '[' \}, \; \text{the sequence of brackets is valid} \\ \text{False} & \text{otherwise} \end{cases} \)

inputFormat

The input consists of a single line which contains a non-empty string s composed of characters: ('(', ')', '{', '}', '[' ,']'). The string may also be empty.

outputFormat

Output a single line containing either True or False (case-sensitive), indicating whether the string is a valid parentheses sequence.

## sample
()
True