#K72417. Valid Parentheses Checker

    ID: 33749 Type: Default 1000ms 256MiB

Valid Parentheses Checker

Valid Parentheses Checker

You are given a string s consisting solely of the characters ('), {'} and [']. Your task is to determine if the string is valid. A valid string meets the following criteria:

  • Every opening bracket must have a corresponding closing bracket of the same type.
  • Opening brackets must be closed in the correct order (i.e. last opened, first closed).

Formally, a string s is considered valid if it satisfies:

$$ s = s_1s_2 \cdots s_n, \quad \text{and for every opening bracket } b, \text{ there exists a closing bracket } b' \text{ such that } b \text{ matches } b' $$

Print YES if the string is valid, otherwise print NO.

inputFormat

The input consists of a single line containing a string s that comprises only the characters '(', ')', '{', '}', '[' and ']'. The string may be empty.

outputFormat

Output a single line: YES if the input string has valid parentheses matching and proper nesting, otherwise NO.

## sample
{[()]}
YES