1class Solution:2def reverseParentheses(self, s: str) -> str:3stack = []4ans = ""5res = deque([])6s = list(s)7for i in s:8if i == ")":9while stack[-1] != "(":10res.append(stack.pop())11stack.pop()12while res:13stack.append(res.popleft())14else:15stack.append(i)16return "".join(stack)