<jupyter_start><jupyter_text>Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:    [      "((()))",      "(()())",      "(())()",      "()(())",      "()()()"    ]  Thought- DFS is the easiest way to do this question for me.<jupyter_code>def dfs(left,right,res,string):
    if right<left:
        return
    if not left and not right:
        res.append(string)
        return
    if left:
        dfs(left-1,right,res,string+'(')
    if right:
        dfs(left,right-1,res,string+')')    
    return res
n=5
dfs(n,n,[],'')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1676923076923077, 'fraction_numerical': 0.006153846153846154, 'mean_word_length': 2.875, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '478691', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 226, 'n_tokens_neox': 220, 'n_words': 57, 'path': '22. Generate Parentheses.ipynb', 'repo_name': 'kkoo1122/Leetcode_Practice', 'size': '650'}