Update 0450.删除二叉搜索树中的节点.md

添加代码高亮
This commit is contained in:
sss1h
2024-02-27 20:26:06 +08:00
committed by GitHub
parent c88104b1af
commit a518db03dd

View File

@ -42,7 +42,7 @@
代码如下:
```
```cpp
TreeNode* deleteNode(TreeNode* root, int key)
```
@ -50,7 +50,7 @@ TreeNode* deleteNode(TreeNode* root, int key)
遇到空返回,其实这也说明没找到删除的节点,遍历到空节点直接返回了
```
```cpp
if (root == nullptr) return root;
```
@ -106,7 +106,7 @@ if (root->val == key) {
这里相当于把新的节点返回给上一层,上一层就要用 root->left 或者 root->right接住代码如下
```
```cpp
if (root->val > key) root->left = deleteNode(root->left, key);
if (root->val < key) root->right = deleteNode(root->right, key);
return root;