ninehills / blog

https://ninehills.tech
758 stars 68 forks source link

LeetCode-32. Longest Valid Parentheses #48

Closed ninehills closed 6 years ago

ninehills commented 7 years ago

问题

https://leetcode.com/problems/longest-valid-parentheses/description/ Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.

For "(()", the longest valid parentheses substring is "()", which has length = 2.

Another example is ")()())", where the longest valid parentheses substring is "()()", which has length = 4.

ninehills commented 7 years ago

4