Module Expr Str Assign NameStore Str ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam defaults body Assign AttributeStore NameLoad attr Dict decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If CompareEq NameLoad Num body Return ListLoad NameLoad Return Call AttributeLoad NameLoad attr Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If CompareNotIn TupleLoad NameLoad NameLoad AttributeLoad NameLoad attr body Assign NameStore ListLoad If CompareGt NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad For NameStore Call NameLoad NameLoad BinOpAdd NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr NameLoad BinOpSub NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr BinOpAdd NameLoad Num NameLoad For NameStore NameLoad body For NameStore NameLoad body Assign NameStore Call NameLoad NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index TupleLoad NameLoad NameLoad NameLoad Return SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore ListLoad If CompareGt NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad For NameStore Call NameLoad NameLoad BinOpAdd NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr NameLoad BinOpSub NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr BinOpAdd NameLoad Num NameLoad For NameStore NameLoad body For NameStore NameLoad body Assign NameStore Call NameLoad NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list decorator_list
N/A N/A 
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.

For example,
Given n = 3, your program should return all 5 unique BST's shown below.

   1         3     3      2      1
    \       /     /      / \           3     2     1      1   3      2
    /     /       \                    2     1         2                 3
confused what "{1,#,2,3}" means? > read more on how binary tree is serialized on OJ.
 N/A __author__ Danyang TreeNode N/A object N/A __init__ N/A N/A self x N/A N/A N/A N/A self val x N/A N/A self left None N/A N/A self right None N/A N/A Solution N/A object N/A __init__ N/A N/A self N/A N/A N/A N/A self cache N/A N/A generateTrees N/A N/A self n N/A N/A N/A 
        dfs
        Catalan
        :param n: integer
        :return: list of TreeNode
         N/A N/A n 0 N/A N/A N/A None N/A N/A N/A self generate_cache 1 n N/A generate_cache N/A N/A self start end N/A N/A N/A 80ms N/A N/A N/A start end N/A self cache N/A N/A roots N/A N/A N/A start end N/A N/A N/A N/A roots append None N/A roots N/A pivot N/A range start N/A end 1 N/A N/A left_roots N/A N/A self generate_cache start N/A pivot 1 N/A right_roots N/A N/A self generate_cache N/A pivot 1 end N/A left_root left_roots N/A N/A right_root right_roots N/A N/A root N/A TreeNode pivot N/A N/A root left left_root N/A N/A root right right_root N/A N/A N/A roots append root N/A N/A N/A self cache N/A N/A start end roots N/A N/A N/A self cache N/A N/A start end N/A generate N/A N/A self start end N/A N/A N/A 
        dfs (cache possible)
        100 ms
        {number| number \in [start, end]}

        Follow the 1st proof of Catalan Number
        :param start: initial number in the array
        :param end: final number in the array
        :return: list of TreeNode
         N/A subtree_roots N/A N/A N/A start end N/A N/A N/A N/A subtree_roots append None N/A subtree_roots N/A pivot N/A range start N/A end 1 N/A N/A left_subtree_roots N/A N/A self generate start N/A pivot 1 N/A right_subtree_roots N/A N/A self generate N/A pivot 1 end N/A left_node left_subtree_roots N/A N/A right_node right_subtree_roots N/A N/A pivot_node N/A TreeNode pivot N/A N/A pivot_node left left_node N/A N/A pivot_node right right_node N/A N/A N/A subtree_roots append pivot_node N/A subtree_roots N/A N/A