We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c88104b commit a518db0Copy full SHA for a518db0
problems/0450.删除二叉搜索树中的节点.md
@@ -42,15 +42,15 @@
42
43
代码如下:
44
45
-```
+```cpp
46
TreeNode* deleteNode(TreeNode* root, int key)
47
```
48
49
* 确定终止条件
50
51
遇到空返回,其实这也说明没找到删除的节点,遍历到空节点直接返回了
52
53
54
if (root == nullptr) return root;
55
56
@@ -106,7 +106,7 @@ if (root->val == key) {
106
107
这里相当于把新的节点返回给上一层,上一层就要用 root->left 或者 root->right接住,代码如下:
108
109
110
if (root->val > key) root->left = deleteNode(root->left, key);
111
if (root->val < key) root->right = deleteNode(root->right, key);
112
return root;
0 commit comments