#K46827. Balanced Brackets Validation

    ID: 28063 Type: Default 1000ms 256MiB

Balanced Brackets Validation

Balanced Brackets Validation

You are given a string consisting exclusively of the characters (, ), {, }, [, and ]. Your task is to determine whether the sequence of brackets is balanced. A sequence is considered balanced if every opening bracket has a corresponding closing bracket in the correct order.

The checking process can be modeled using a stack: push every opening bracket, and for every closing bracket, verify that it matches the most recent unmatched opening bracket.

Formally, if we denote the sequence by \(s\) with \(1 \leq |s| \leq 1000\), then the sequence is balanced if and only if: $$ \text{For every opening bracket there exists a corresponding closing bracket in the correct order.} $$

inputFormat

The input consists of a single line containing the bracket sequence.

outputFormat

Output a single line: True if the bracket sequence is balanced, or False otherwise.

## sample
(){}[]
True