Store current longest valid string on stack, add to it when popped (python)
A couple of the highest voted solutions are similar, but this was the easist way for me to understand it. Whenever we see a new open paren, we push the current 
A couple of the highest voted solutions are similar, but this was the easist way for me to understand it. Whenever we see a new open paren, we push the current longest streak to the stack. Whenever we see a close paren, we pop the top value if possible, and add the value (which was the previous longest streak up to that point) to the current one (because they are now contiguous) and add 2 to count for the matching open and close parens. If there is no matching open paren for a close paren, reset the current count. Observe:\n\n```\nclass Solution:\n    def longestValidParentheses(self, s: str) -> int:\n        stack, curr_longest, max_longest = [], 0, 0\n        for c in s:\n            if c == \'(\':\n                stack.append(curr_longest)\n                curr_longest = 0\n            elif c == \')\':\n                if stack:\n                    curr_longest += stack.pop() + 2\n                    max_longest = max(max_longest, curr_longest)\n                else:\n                    curr_longest = 0\n        return max_longest\n```
['Python']