Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a518db0

Browse files
Update 0450.删除二叉搜索树中的节点.md
添加代码高亮
1 parent c88104b commit a518db0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎problems/0450.删除二叉搜索树中的节点.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242

4343
代码如下:
4444

45-
```
45+
```cpp
4646
TreeNode* deleteNode(TreeNode* root, int key)
4747
```
4848
4949
* 确定终止条件
5050
5151
遇到空返回,其实这也说明没找到删除的节点,遍历到空节点直接返回了
5252
53-
```
53+
```cpp
5454
if (root == nullptr) return root;
5555
```
5656

@@ -106,7 +106,7 @@ if (root->val == key) {
106106

107107
这里相当于把新的节点返回给上一层,上一层就要用 root->left 或者 root->right接住,代码如下:
108108

109-
```
109+
```cpp
110110
if (root->val > key) root->left = deleteNode(root->left, key);
111111
if (root->val < key) root->right = deleteNode(root->right, key);
112112
return root;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /