#C4645. Valid Parentheses Problem
Valid Parentheses Problem
Valid Parentheses Problem
Given a string s
consisting solely of the characters '(' and ')', determine if the string is a valid sequence of parentheses.
A valid sequence must satisfy the following conditions:
- Every open parenthesis '(' has a corresponding close parenthesis ')'.
- Open parentheses must be closed in the correct order.
For example, the string "(())" is valid, while "()(" is not.
The solution should read input from standard input and print the result to standard output.
inputFormat
A single line containing the string s
. The string contains only the characters '(' and ')'. The length of s
can be zero.
outputFormat
Print a single line with True
if the sequence of parentheses is valid, and False
otherwise.## sample
()
True