Parenthesis Gen | Backtracking | C++ Solution
Parenthesis Gen, is a Backtracking related problem and in this post we will see how we can solve this challenge in C++
Generate all Parentheses IIBookmark Suggest Edit Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses of length 2*n.
For example, given n = 3, a solution set is:
"((()))", "(()())", "(())()", "()(())", "()()()" Make sure the returned list of strings are sorted. there are two options for each position: it can be ')' or '(' when all the brackets are placed no. of opening braces shouldn't be greater than n no. of closing braces should not be greater than opening braces driver function for keeping track of closing brace for opening brace for keeping track of total brackets unordered_map<string,int> h;
Please check the main.cpp snippet for the solution.
This solution originally posted at: Github by @susantabiswas