#K42327. Balanced Brackets Checker

    ID: 27063 Type: Default 1000ms 256MiB

Balanced Brackets Checker

Balanced Brackets Checker

Given an expression that contains various types of brackets (), [] and {}, determine whether the expression is balanced. An expression is considered balanced if:

  • Every opening bracket has a corresponding closing bracket.
  • The brackets close in the correct order.

Note that the expression may also contain other characters which should be ignored. For instance, the expression \(\{[()]\}\) is balanced and should return YES, while \(\{[(])\}\) is not balanced and should return NO.

inputFormat

The input is read from stdin and consists of a single line containing the expression string.

outputFormat

The output should be printed to stdout. Output YES if the expression is balanced, and NO otherwise.

## sample
()
YES