Question bank › Stack
Dsa Stack Medium

Maximum Nesting Depth of Parentheses

Given a string containing only parentheses '(', ')', write a program to determine the maximum nesting depth of the parentheses. The nesting depth is defined as the maximum number of parentheses that are open at one time. Input The input consists of a single line containing the string of parentheses. Output Print a single integer representing the maximum nesting depth. Example Input: ((())) Output: 3

Key concepts

stackdepthcounting

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.