#C7530. Bracket Balance Validation
Bracket Balance Validation
Bracket Balance Validation
In this problem, you are given a string that may contain various characters including the brackets ()
, {}
, and []
. Your task is to determine whether these brackets are correctly nested and balanced.
The brackets are considered balanced if every opening bracket has a corresponding closing bracket in the correct order. For example, the string {[()]}
is balanced, while {[(])}
is not.
Note that the input string can also contain non-bracket characters which should be ignored when checking for balance.
inputFormat
A single line input containing a string of characters. The string may include alphabets, digits, symbols and the brackets '()', '{}', '[]'. The length of the string is between 1 and 10^5.
outputFormat
Output a single line: "YES" if the brackets in the input string are balanced, otherwise "NO".## sample
{[()]}
YES