#K34002. Balanced Brackets Checker
Balanced Brackets Checker
Balanced Brackets Checker
The problem is to determine whether a given string of characters containing brackets is balanced. A string is considered balanced if every opening bracket has a corresponding closing bracket in the correct order. The supported brackets are: (), {}, []. Characters other than these brackets should be ignored.
For example, the string {[()]}
is balanced while the string {[(])}
is not. The solution should read a single line from standard input (stdin) and output the result to standard output (stdout) as either Balanced
or Unbalanced
.
Note: In any formulas, please use LaTeX format. For instance, the bracket pairs can be denoted as \( ( ) \), \( { } \) and \( [ ] \).
inputFormat
The input consists of a single line string s
which may include letters, digits, symbols, and brackets. Only the brackets ( )
, { }
, and [ ]
are used in determining the output.
Example: {[a+b]*(c-d)/(e+f)}
outputFormat
Output a single line: Balanced
if the brackets in the input string are balanced, or Unbalanced
otherwise.
([{}])
Balanced