TreeNode* constructMaximumBinaryTree(vector<int>& nums){ if (nums.empty()) { returnNULL; } auto iter = max_element(nums.begin(), nums.end()); vector<int> left, right; for (auto i = nums.begin(); i != nums.end(); i++) { if (i < iter) { left.push_back(*i); } if (i > iter) { right.push_back(*i); } } TreeNode* root = new TreeNode(*iter); root->left = constructMaximumBinaryTree(left); root->right = constructMaximumBinaryTree(right); return root; }