#K58327. Balanced Brackets Checker

    ID: 30618 Type: Default 1000ms 256MiB

Balanced Brackets Checker

Balanced Brackets Checker

You are given a string s which may contain various characters. Your task is to determine if the string has balanced brackets. Only the following bracket characters are considered: ( ), { }, and [ ]. A string is said to be balanced if:

  • Every opening bracket has a corresponding closing bracket of the same type.
  • Brackets are closed in the correct order.

This can be formally defined using the following condition in LaTeX:
\( \text{For every } i, \; s_i \in \{ '(', '{', '[' \} \text{ there exists a } j > i \text{ such that } s_j \in \{ ')', '}', ']' \} \text{ and the sequence between them is balanced.} \)

Ignore any characters that are not one of the above brackets.

inputFormat

The input consists of a single line from stdin containing the string s.

Note: The string can include spaces and other non-bracket characters, which should be ignored for balance checking.

outputFormat

Print a single line to stdout with True if the brackets in the string are balanced, otherwise False.

Balanced means that every opening bracket has a corresponding closing bracket in the correct order.

## sample
()
True