#K5056. Balanced Brackets

    ID: 28891 Type: Default 1000ms 256MiB

Balanced Brackets

Balanced Brackets

Given a string consisting solely of the characters ('), (')', '{','}', '[' and ']', determine if the sequence of brackets is balanced.

A string is balanced if:

  1. Every opening bracket has a corresponding closing bracket.
  2. Brackets are closed in the correct order. For example, {[()]} is balanced, but {[(])} is not.

The input will be supplied via standard input, and the result must be printed on the standard output.

inputFormat

The input consists of a single line containing a string of brackets. The string will contain only the characters ('), (')', '{','}', '[' and ']'.

outputFormat

Print a single line: YES if the string of brackets is balanced, and NO otherwise.

## sample
{[()]}
YES

</p>