Dsa
Stack
Hard
String Reversal through Parentheses
Write a program that reverses sections of a string enclosed in parentheses. For each pair of parentheses, reverse the characters inside them. For nested parentheses, work from the innermost to the outermost. Print the final string after all reversals.
Example:
Input:
abc(def(ghi)jkl)mno
Output:
abc(ihg)jklmno
Key concepts
stackstring manipulationreversal
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