std::vector<std::string>
res;
30 void makeStrings(std::string str,
intn,
intclosed,
intopen);
33std::vector<std::string>
generate(
intn);
46 intclosed,
intopen) {
50 if((str.length() == 2 * n) &&
55 if(str.length() == 2 * n) {
72std::string str =
"(";
84std::vector<std::string> patterns;
88patterns = {{
"()"}};
92patterns = {{
"()()()"}, {
"()(())"}, {
"(())()"}, {
"(()())"}, {
"((()))"}};
97patterns = {{
"()()()()"}, {
"()()(())"}, {
"()(())()"}, {
"()(()())"},
98{
"()((()))"}, {
"(())()()"}, {
"(())(())"}, {
"(()())()"},
99{
"(()()())"}, {
"(()(()))"}, {
"((()))()"}, {
"((())())"},
100{
"((()()))"}, {
"(((())))"}};
101assert(p.
generate(n) == patterns);
103std::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.
int main()
Main function.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4