Please solve the programming task below using a self-contained code snippet in a markdown code block.

Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.
 
Please complete the following python code precisely:
```python
class Solution:
    def longestValidParentheses(self, s: str) -> int:
```