#C14676. Balanced Parentheses Checker
Balanced Parentheses Checker
Balanced Parentheses Checker
Given a string expression containing various types of parentheses including round brackets \(( )\), square brackets \([ ]\), and curly braces \({ }\), determine if the expression has balanced parentheses.
An expression is said to be balanced if for every opening bracket there is a corresponding closing bracket in the correct order. For example, in a balanced expression, every \( ( \) must be closed by a corresponding \( ) \), every \( [ \) must be closed by a corresponding \( ] \), and every \( { \) must be closed by a corresponding \( } \).
Your task is to implement a function that reads an expression from standard input and outputs True
if the expression is balanced or False
otherwise.
inputFormat
The input consists of a single line containing the expression as a string. The string might be empty.
outputFormat
Output a single line: True
if the expression has balanced parentheses, and False
otherwise.
(a[0]+b[2c[6]]) - {24 + [14 - 5]}
True