#C9222. Valid Parentheses Checker
Valid Parentheses Checker
Valid Parentheses Checker
Given a string consisting solely of the characters '(' and ')', determine whether the string is a valid sequence of balanced parentheses.
A string is considered valid if:
- Every opening parenthesis '(' has a corresponding closing parenthesis ')'.
- Each closing parenthesis matches the most recent unmatched opening parenthesis.
Formally, a string s is valid if it satisfies the following recursive definition:
\(\text{Valid}(s) = \begin{cases}\text{True}, & \text{if } s = "" \\ \text{True}, & \text{if } s = "(" + t + ")" \text{ and } \text{Valid}(t) \\ \text{False}, & \text{otherwise} \end{cases}\)
Your task is to check whether the input string is a valid parentheses string and output "Yes" if it is, and "No" otherwise.
inputFormat
The input consists of a single string s containing only the characters '(' and ')'. The string is provided through standard input (stdin). It may be empty.
outputFormat
Output a single line containing either "Yes" if the input string s is a valid parentheses string, or "No" if it is not. The output should be printed to standard output (stdout).
## sample()
Yes