Question bank › Stack
Dsa Stack Medium

Parenthesis Depth

Given a string of parentheses, calculate the maximum depth of nested parentheses. You should consider '(' as pushing into depth and ')' as popping from it. Input format: A single line containing the string of parentheses. Output format: Print the maximum depth of the nested parentheses. 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
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.