#C12707. Balanced Parentheses Checker
Balanced Parentheses Checker
Balanced Parentheses Checker
Given a string \(S\) consisting solely of the characters '(' and ')', determine if the string represents a balanced sequence of parentheses. A sequence is considered balanced if for every opening parenthesis \( ( \) there is a corresponding closing parenthesis \( ) \) and the parentheses are properly nested.
For example, the string ()
is balanced, while ((())
is not.
Please note that the input might be large, so consider efficient methods for reading input from stdin.
inputFormat
The input consists of a single string composed only of the characters '(' and ')'. The entire input is provided through stdin (standard input).
outputFormat
Print a single line output: True
if the sequence of parentheses is balanced; otherwise, print False
. The output should be written to stdout (standard output).
()
True