Dsa
Stack
Medium
Maximal Parentheses Depth
Given a string consisting of '(' and ')', your task is to determine the maximum depth of the parentheses in the string. The depth is defined as the maximum level of nested parentheses. If the string is not valid, return -1.
Example input:
((())())
Output:
2
Key concepts
stackdepthparentheses
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