Question bank › Recursion
Dsa Recursion Warm-up

The Nested Key

You are given a string representing nested containers using parentheses, and a single character 'X' hidden inside. Your task is to find the nesting depth of 'X'. A character at the top level (no parentheses) has depth 0. Each layer of '()' increases depth by 1. Input Format: A string containing only '(', ')', and 'X'. Output Format: An integer. Example: Input: ((X)) Output: 2

Key concepts

recursionparsing

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.