MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / generateParenthesis

Method generateParenthesis

22. Generate Parentheses/Solution.cpp:46–51  ·  view source on GitHub ↗

backtracing The idea is intuitive. Use two integers to count the remaining left parenthesis (n) and the right parenthesis (m) to be added. At each function call add a left parenthesis if n > 0 and add a right parenthesis if m>0. Append the result and terminate recursive calls when both m and n are zero. */

Source from the content-addressed store, hash-verified

44 when both m and n are zero.
45 */
46 vector<string> generateParenthesis(int n) {
47 vector<string> res;
48 string s = "";
49 this->bt(res,n,n,s);
50 return res;
51 }
52
53 void bt(vector<string> & v, int l, int r, string & str) {
54 if (l == 0 and r == 0) {

Callers

nothing calls this directly

Calls 1

btMethod · 0.95

Tested by

no test coverage detected