Valid Parentheses (every bracket closes with the same type in the right order) for s = "(]" and s = "((". Which check is complete?
Show answer
Answer
Match each closer to the stack top and return True only if the stack is empty at the end
Both conditions matter: "(]" mismatches and "((" leaves items on the stack. Counting types accepts "([)]". Skipping the final empty check accepts "((". The mirror check rejects valid strings like "()()".
Source: LeetCode 20. Valid Parentheses