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 d61256c commit 74556cfCopy full SHA for 74556cf
backtracking/generate_parentheses_iterative.py
@@ -5,7 +5,8 @@ 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 along with
9
+ the counts of '(' and ')'.
10
4. While the stack is not empty:
11
a. Pop a partial combination and its open and close counts from the stack.
12
b. If the combination length is equal to 2*length, add it to the result.
0 commit comments