#K38167. Balanced Parentheses Checker

    ID: 26139 Type: Default 1000ms 256MiB

Balanced Parentheses Checker

Balanced Parentheses Checker

Given a string s consisting of characters '(', ')', '{', '}', '[' and ']', determine whether the parentheses in the string are balanced.

A string is considered balanced if every opening bracket has a corresponding closing bracket in the correct order. Formally, if we denote the stack of opening brackets by \( S \), the string is balanced if and only if after processing every character, \( S \) is empty.

Examples:

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

Your task is to implement a solution that reads the input string from standard input (stdin) and outputs True if the string is balanced, or False otherwise, to standard output (stdout).

inputFormat

The input consists of a single line containing the string s. The string may be empty and will contain only the characters '(', ')', '{', '}', '[' and ']'.

outputFormat

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

## sample
()
True