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 c954633 commit 6fdefcfCopy full SHA for 6fdefcf
backtracking/generate_parentheses_iterative.py
@@ -5,7 +5,7 @@ def generate_parentheses_iterative(length: int) -> list[str]:
5
The algorithm works as follows:
6
1. Initialize an empty list to store the combinations.
7
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 ')'.
+ 3. Start with empty string and push it on stack with the counts of '(' and ')'.
9
4. While the stack is not empty:
10
a. Pop a partial combination and its open and close counts from the stack.
11
b. If the combination length is equal to 2*length, add it to the result.
0 commit comments