generate_parentheses class
More...
◆ generate()
wrapper interface
- Parameters
-
n | number of pairs of parentheses |
- Returns
- all well-formed pattern of parentheses
70 {
75}
std::vector< std::string > res
Contains all possible valid patterns.
Definition generate_parentheses.cpp:28
void makeStrings(std::string str, int n, int closed, int open)
function that adds parenthesis to the string.
Definition generate_parentheses.cpp:45
◆ makeStrings()
void backtracking::generate_parentheses::makeStrings |
( |
std::string | str, |
|
|
int | n, |
|
|
int | closed, |
|
|
int | open ) |
|
private |
function that adds parenthesis to the string.
- Parameters
-
str | string build during backtracking |
n | number of pairs of parentheses |
closed | number of closed parentheses |
open | number of open parentheses |
46 {
47 if (closed > open)
48 return;
49
50 if ((str.
length() == 2 * n) &&
51 (closed != open)) {
52 return;
53 }
54
55 if (str.
length() == 2 * n) {
57 return;
58 }
59
62}
The documentation for this class was generated from the following file: