File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ function-naming-style=snake_case
38
38
good-names =i,
39
39
j,
40
40
k,
41
+ n,
42
+ s,
43
+ t,
41
44
ex,
42
45
Run,
43
46
_
Original file line number Diff line number Diff line change @@ -7,14 +7,15 @@ def generate_parenthesis(num: int) -> list[str]:
7
7
Space Complexity: O(1)
8
8
Time Complexity: O(n)
9
9
"""
10
+
10
11
def generate (open_count : int , close_count : int , gen : str ):
11
12
if open_count == num and close_count == num :
12
13
ans .append (gen )
13
14
return
14
15
if open_count < num :
15
- generate (open_count + 1 , close_count , gen + '(' )
16
+ generate (open_count + 1 , close_count , gen + "(" )
16
17
if open_count > close_count :
17
- generate (open_count , close_count + 1 , gen + ')' )
18
+ generate (open_count , close_count + 1 , gen + ")" )
18
19
19
20
ans = []
20
21
generate (0 , 0 , "" )
You can’t perform that action at this time.
0 commit comments