Skip to content

Commit d2d83c2

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 95e9aa1 commit d2d83c2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

backtracking/generate_parentheses_iterative.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def generate_parentheses_iterative(length: int) -> list:
22
"""
33
Generate all valid combinations of parentheses (Iterative Approach).
4-
4+
55
The algorithm works as follows:
66
1. Initialize an empty list to store the combinations.
77
2. Initialize a stack to keep track of partial combinations.
@@ -12,16 +12,16 @@ def generate_parentheses_iterative(length: int) -> list:
1212
c. If open count is < length, push new combination with added '(' onto the stack.
1313
d. If close count < open count, push new combination with added ')' on stack.
1414
5. Return the result containing all valid combinations.
15-
15+
1616
Args:
1717
length: The desired length of the parentheses combinations
18-
18+
1919
Returns:
2020
A list of strings representing valid combinations of parentheses
21-
21+
2222
Time Complexity:
2323
O(2^(2n))
24-
24+
2525
Space Complexity:
2626
O(2^(2n))
2727

0 commit comments

Comments
 (0)