第20976题 单选题
删除有两个孩子的二叉排序树节点时,给定C++代码横线处应填入什么?

其中findMax和findMin分别为寻找树的最大值和最小值的函数。

struct TreeNode {    int val;    TreeNode* left;    TreeNode* right;    TreeNode(int x): val(x), left(nullptr), right(nullptr) {}};TreeNode* deleteNode(TreeNode* root, int key) {    if (!root) return nullptr;    if (key < root->val) {        root->left = deleteNode(root->left, key);    }    else if (key > root->val) {        root->right = deleteNode(root->right, key);    }    else {        if (!root->left) return root->right;        if (!root->right) return root->left;        TreeNode* temp = ____________; // 在此处填写代码        root->val = temp->val;        root->right = deleteNode(root->right, temp->val);    }    return root;}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析