Skip to content

Commit 74556cf

Browse files
Update generate_parentheses_iterative.py
1 parent d61256c commit 74556cf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

backtracking/generate_parentheses_iterative.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ def generate_parentheses_iterative(length: int) -> list[str]:
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.
8-
3. Start with empty string and push it on stack along with the counts of '(' and ')'.
8+
3. Start with empty string and push it on stack along with
9+
the counts of '(' and ')'.
910
4. While the stack is not empty:
1011
a. Pop a partial combination and its open and close counts from the stack.
1112
b. If the combination length is equal to 2*length, add it to the result.

0 commit comments

Comments
 (0)