Dsa
Sliding Window
Medium
Balanced Parentheses Substring
Given a string containing only parentheses, find the length of the longest valid parentheses substring. A valid parentheses substring has every opening parenthesis matched with a closing parenthesis.
Input:
A single string s (1 <= |s| <= 10^5).
Output:
An integer representing the length of the longest valid parentheses substring.
Example:
Input:
(()))()
Output:
4
Key concepts
sliding_windowstringstack
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now