#K5056. Balanced Brackets
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:
- Every opening bracket has a corresponding closing bracket.
- 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.
{[()]}
YES
</p>