1void find_balanced_braces(size_t const &n, size_t open, size_t close, size_t index, string &s, vector<string> &res){
2 if(open == n and close == n)
3 res.push_back(s);
4 else{
5 if(open < n){
6 s[index] = '(';
7 find_balanced_braces(n, open+1, close, index+1, s, res);
8 }
9 if(close < open){
10 s[index] = ')';
11 find_balanced_braces(n, open, close+1, index+1, s, res);
12 }
13 }
14}
15
16find_balanced_braces(n, 0, 0, 0, s, res);