#K66982. Balanced Brackets Checker

    ID: 32541 Type: Default 1000ms 256MiB

Balanced Brackets Checker

Balanced Brackets Checker

You are given a string s consisting only of the characters '(', ')', '{', '}', '[' and ']'. A string is considered balanced if:

  • Every opening bracket has a corresponding closing bracket of the same type.
  • The brackets are closed in the correct order.
For example, the string {[()]} is balanced, while {[(])} is not.

Your task is to determine whether the given string is balanced. If it is balanced, print YES, otherwise print NO.

inputFormat

A single line containing a string s which includes only the characters '(', ')', '{', '}', '[' and ']'. The string may be empty. Input is read from standard input (stdin).

outputFormat

Output a single line: YES if the input string is balanced, and NO otherwise. The output should be written to standard output (stdout).## sample

{[()]}
YES