Longest Valid Parentheses

Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.

Constraints

  • 0 <= s.length <= 30000
  • s[i] is '(' or ')'
Saving… · 3 lines
class Solution:
def longestValidParentheses(self, s: str) -> int:

Console

Click Run to execute sample tests.