Given a string with '(', ')', and '', determine if it can be valid. The '' can be '(', ')', or empty. For ", it is valid ('' can be ')'). For ", also valid ('' is empty). For , invalid. Track the range of possible open parentheses counts. Tricky: the '*' wildcard introduces ambiguity.
You do not know which role it plays until you finish scanning. The range-based greedy tracks all possible open counts simultaneously, avoiding the need to try all assignments where is the number of '*'.