Skip to content

Commit 91a21cc

Browse files
authored
Update Solution2.py
1 parent ad7c0bd commit 91a21cc

File tree

1 file changed

+4
-4
lines changed
  • solution/1100-1199/1190.Reverse Substrings Between Each Pair of Parentheses

1 file changed

+4
-4
lines changed

solution/1100-1199/1190.Reverse Substrings Between Each Pair of Parentheses/Solution2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ def reverseParentheses(self, s: str) -> str:
44
d = [0] * n
55
stk = []
66
for i, c in enumerate(s):
7-
if c == '(':
7+
if c == "(":
88
stk.append(i)
9-
elif c == ')':
9+
elif c == ")":
1010
j = stk.pop()
1111
d[i], d[j] = j, i
1212
i, x = 0, 1
1313
ans = []
1414
while i < n:
15-
if s[i] in '()':
15+
if s[i] in "()":
1616
i = d[i]
1717
x = -x
1818
else:
1919
ans.append(s[i])
2020
i += x
21-
return ''.join(ans)
21+
return "".join(ans)

0 commit comments

Comments
 (0)