Dsa
Recursion
Warm-up
The Nested Multiplier
You are given a string representing a number nested within several pairs of parentheses. Each pair of parentheses doubles the value of everything inside it. Use recursion to find the final value.
Input: A string S consisting of zero or more '(' followed by an integer, followed by matching ')'.
Output: The computed integer value.
Example:
Input: ((10))
Output: 40
(Explanation: (10) = 20, so ((10)) = 40)
Key concepts
recursionparsingstrings
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