text made of lowercase English letters and parentheses, and the parentheses are properly balanced.
For every matching pair of parentheses, reverse whatever lies between them, working from the innermost pairs outward. Return the final string with all parentheses removed.text="x(yz)w" → 'xzyw'
Inside the brackets yz turns into zy, giving xzyw.
text="(ab(cd)ef)" → 'fecdba'
First cd → dc, giving abdcef; then the outer pair reverses everything: fecdba.
text="()q" → 'q'
Empty brackets simply vanish.
text consists of lowercase English letters, ( and )text="x(yz)w"
'xzyw'
Run checks the first 3 tests in your browser. Submit checks all 66 tests on the server, hidden ones included.