您当前的位置: 首页 >  搜索

对方正在debug

暂无认证

  • 4浏览

    0关注

    399博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

不同的二叉搜索树II(nullptr)

对方正在debug 发布时间:2020-02-19 19:49:59 ,浏览量:4

题目:https://leetcode-cn.com/problems/unique-binary-search-trees-ii/ 代码:https://leetcode-cn.com/problems/unique-binary-search-trees-ii/solution/c-30xing-dai-ma-di-gui-by-black-hole/

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    vector helper(int start,int end){
        vector ret;
        if(start > end)
            ret.push_back(nullptr);
        
        for(int i=start;i left = l;
                    root -> right = r;
                    ret.push_back(root);
                }
            }
        }
        return ret;
    }
    
    vector generateTrees(int n) {
        vector ret;
        if(n == 0)
            return ret;    
        ret = helper(1,n);
        return ret;
    }
};
关注
打赏
1664895754
查看更多评论
立即登录/注册

微信扫码登录

0.0639s