class Solution {
List<String> generateParentheses(int n) {
List<String> result = new ArrayList<>();
if (n == 0) {
String empty = "";
result.add(empty);
}
else {
for (int closure = 0; closure < n; closure++)
for (String left: generateParentheses(closure))
for (String right: generateParentheses(n - closure - 1))
result.add("(" + left + ")" + right);
}
return result;
}
}
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
char ** generateParenthesis(int n, int* returnSize){
}
function generateParenthesis(n: number): string[] {
};
public class Solution {
public IList<string> GenerateParenthesis(int n) {
}
}
/**
* @param {number} n
* @return {string[]}
*/
var generateParenthesis = function(n) {
};
class Solution {
func generateParenthesis(_ n: Int) -> [String] {
}
}
class Solution {
/**
* @param Integer $n
* @return String[]
*/
function generateParenthesis($n) {
}
}
class Solution {
public:
vector<string> generateParenthesis(int n) {
}
};
class Solution {
public List<String> generateParenthesis(int n) {
}
}
# @param {Integer} n
# @return {String[]}
def generate_parenthesis(n)
end