#C5019. Balanced Braces Checker

    ID: 48622 Type: Default 1000ms 256MiB

Balanced Braces Checker

Balanced Braces Checker

You are given a string consisting solely of the characters (, ), {, }, [, and ]. Your task is to determine if the braces in the string are balanced.

A sequence is considered balanced if:

  • Every opening brace has a corresponding closing brace.
  • The braces are closed in the correct order.

For example, the string ({[]}) is balanced, while ([)] is not.

One common approach is to use a stack. Every time an opening brace is encountered, it is pushed onto the stack. When a closing brace comes, it must match the type of the top item in the stack. In mathematical terms, if we denote the stack as S, then the sequence is balanced if and only if:

\( S = \varnothing \) after processing the entire string.

inputFormat

The input consists of a single line containing a non-empty string with only the characters (, ), {, }, [, and ]. If the string is empty, consider it as balanced.

outputFormat

Output a single line: True if the string of braces is balanced, and False otherwise.

## sample
({[]})
True