【代码随想录37期】Day20 最大二叉树、合并二叉树、二叉搜索树中的搜索、验证二叉搜索树

最大二叉树

class Solution {
   
public:
    TreeNode* constructMaximumBinaryTree(vector<int>& nums) {
   
        return construct(nums, 0, nums.size() - 1);
    }

    TreeNode* construct(const vector<int>& nums, int left, int right) {
   
        if (left > right) {
   
            return nullptr;
        }
        int best = left;
        for (int i = left + 1

你可能感兴趣的:(C++,leetcode,基础练习,算法,数据结构)