#C13137. Balanced Parentheses Checker

    ID: 42642 Type: Default 1000ms 256MiB

Balanced Parentheses Checker

Balanced Parentheses Checker

Your task is to determine whether an input string contains balanced brackets. The string may include any characters, but only the following brackets are significant:

  • ( )
  • { }
  • [ ]

An expression is considered balanced if every opening bracket has a corresponding closing bracket in the correct order. For example, the string (a[b{c}d]) is balanced, whereas ([a{b}c)d] is not. Formally, if we denote an opening bracket as \(b_i\) and the corresponding closing bracket as \(b_j\), then the string is balanced if:

\( \forall\, b_i,\, \exists\, b_j\, \text{such that they match and the order is maintained} \)

Ignore any characters that are not brackets.

inputFormat

The input consists of a single line containing the string expression that may include letters, digits, spaces, and different types of brackets.

outputFormat

Output a single line: True if the expression is balanced, and False otherwise.

## sample
(a[b{c}d])
True