We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d07a84f commit c6bb4c7Copy full SHA for c6bb4c7
problems/problem_1190/solution_1.py
@@ -0,0 +1,42 @@
1
+import pytest
2
+
3
4
+class Solution:
5
+ def reverseParentheses(self, s: str) -> str:
6
+ stack = []
7
+ for c in s:
8
+ if c == ")":
9
+ temp = []
10
+ while stack[-1] != "(":
11
+ temp.append(stack.pop())
12
+ stack.pop()
13
+ stack.extend(temp)
14
+ else:
15
+ stack.append(c)
16
+ return "".join(stack)
17
18
19
+tests = [
20
+ (
21
+ ("(abcd)",),
22
+ "dcba",
23
+ ),
24
25
+ ("(u(love)i)",),
26
+ "iloveu",
27
28
29
+ ("(ed(et(oc))el)",),
30
+ "leetcode",
31
32
+]
33
34
35
+@pytest.mark.timeout(2)
36
+@pytest.mark.parametrize(
37
+ "inputs, expected",
38
+ tests,
39
+)
40
+def test_validator(inputs, expected):
41
+ output = Solution().reverseParentheses(*inputs)
42
+ assert output == expected
0 commit comments