Best Python Solution (Beats 100%)
\nclass Solution:\n    def longestValidParentheses(self, s):\n        """\n        :type s: str\n        :rtype: int\n        """\n        stack = [0]\n        
```\nclass Solution:\n    def longestValidParentheses(self, s):\n        """\n        :type s: str\n        :rtype: int\n        """\n        stack = [0]\n        longest = 0\n        \n        for c in s:\n            if c == "(":\n                stack.append(0)\n            else:\n                if len(stack) > 1:\n                    val = stack.pop()\n                    stack[-1] += val + 2\n                    longest = max(longest, stack[-1])\n                else:\n                    stack = [0]\n\n        return longest\n```
[]