題庫
00:00

30. Longest Valid Parentheses

困難堆疊AmazonGoogle

Given a string containing only parentheses, return the length of the longest valid parentheses substring.

範例 1:

輸入: s = "(()"
輸出: 2

範例 2:

輸入: s = ")()())"
輸出: 4

限制條件:

  • 0 <= s.length <= 3 * 10^4
核心程式碼模式
● 已自動儲存第 1 行,第 1 欄