28 std::vector<std::string>
res;
30 void makeStrings(std::string str,
int n,
int closed,
int open);
33 std::vector<std::string>
generate(
int n);
46 int closed,
int open) {
50 if ((str.length() == 2 * n) &&
55 if (str.length() == 2 * n) {
72 std::string str =
"(";
84 std::vector<std::string> patterns;
92 patterns = {{
"()()()"}, {
"()(())"}, {
"(())()"}, {
"(()())"}, {
"((()))"}};
97 patterns = {{
"()()()()"}, {
"()()(())"}, {
"()(())()"}, {
"()(()())"},
98 {
"()((()))"}, {
"(())()()"}, {
"(())(())"}, {
"(()())()"},
99 {
"(()()())"}, {
"(()(()))"}, {
"((()))()"}, {
"((())())"},
100 {
"((()()))"}, {
"(((())))"}};
103 std::cout <<
"All tests passed\n";
generate_parentheses class
std::vector< std::string > res
Contains all possible valid patterns.
void makeStrings(std::string str, int n, int closed, int open)
function that adds parenthesis to the string.
std::vector< std::string > generate(int n)
wrapper interface
static void test()
Self-test implementations.