#K61627. Balanced Parentheses Checker

    ID: 31352 Type: Default 1000ms 256MiB

Balanced Parentheses Checker

Balanced Parentheses Checker

Given a string s containing various types of brackets - parentheses (), square brackets [], and curly braces {} - determine whether the brackets are balanced and properly nested.

The string may also contain other characters which should be ignored. A string is considered balanced if every opening bracket has a corresponding closing bracket in the correct order. Formally, the condition can be expressed as:

\( \text{For every } c \text{ in } s, \text{ if } c \in \{'(', '[', '{'\}, \text{ then there must exist a corresponding } c' \text{ such that } c' \in \{')', ']', '}'\} \text{ with proper nesting.} \)

For example:

  • (){}[] is balanced.
  • (] is not balanced.
  • ([)] is not balanced.

Your task is to implement a program that uses standard input and output. The program should read a single string from stdin and output True if the string has balanced brackets, otherwise output False.

inputFormat

The input consists of a single line containing a string s (0 ≤ |s| ≤ 105). The string may include any visible ASCII characters.

outputFormat

Output a single line: True if the input string has balanced brackets, otherwise False.

## sample
(){}[]
True