TreeNode* constructMaximumBinaryTree(vector<int>& nums){ if (nums is empty) returnnullptr; int index = -1,maxval = INT_MIN,n =nums.size(); for (int i = 0;i < n; i++) { if (maxval < nums[i]) { maxval = nums[i]; index = i; } }
TreeNode* createTree(vector<int>& nums,int lo,int hi){ if (lo > hi) returnnullptr; int index = -1,maxval = INT_MIN; for (int i = lo; i <= hi; i++) { if (maxval < nums[i]) { maxval = nums[i]; index = i; } }