#C12705. Balanced Parentheses Checker
Balanced Parentheses Checker
Balanced Parentheses Checker
Given a string S, determine whether the parentheses in the string are balanced. A string is said to have balanced parentheses if each opening parenthesis '(' has a corresponding closing parenthesis ')' and the pairs are properly nested.
This problem can be formally described as follows: Given a string \( S \), check whether it satisfies the following condition:
\[ \text{For every } '(' \text{ in } S, \text{ there exists a matching } ')' \text{ that comes after it and all such matches are non-overlapping.} \]Note that the string may contain other characters which should be ignored when checking for balanced parentheses.
inputFormat
The input consists of a single line string S read from standard input.
outputFormat
Print True
if the parentheses in the input string are balanced, and False
otherwise. The output should be printed to standard output.
()()
True