Question bank › Stack
Dsa Stack Warm-up

Max Scope Depth

In a custom programming language, scopes are defined by opening parentheses '(' and closing parentheses ')'. A valid program must have balanced parentheses. Your task is to find the maximum nesting depth of the scopes. If the parentheses are not balanced (e.g., '(()' or '())'), output -1. Example: Input: (())()(()(())) Output: 3

Key concepts

stackcounters

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.