From c88104b1af80e11ce78ff84147016421b905910c Mon Sep 17 00:00:00 2001 From: sss1h <49825610+sss1h@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:25:03 +0800 Subject: [PATCH] =?UTF-8?q?Update=200669.=E4=BF=AE=E5=89=AA=E4=BA=8C?= =?UTF-8?q?=E5=8F=89=E6=90=9C=E7=B4=A2=E6=A0=91.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加代码高亮 --- problems/0669.修剪二叉搜索树.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/problems/0669.修剪二叉搜索树.md b/problems/0669.修剪二叉搜索树.md index 916013c5..6824c7e2 100644 --- a/problems/0669.修剪二叉搜索树.md +++ b/problems/0669.修剪二叉搜索树.md @@ -79,7 +79,7 @@ public: 代码如下: -``` +```cpp TreeNode* trimBST(TreeNode* root, int low, int high) ``` @@ -87,7 +87,7 @@ TreeNode* trimBST(TreeNode* root, int low, int high) 修剪的操作并不是在终止条件上进行的,所以就是遇到空节点返回就可以了。 -``` +```cpp if (root == nullptr ) return nullptr; ``` @@ -97,7 +97,7 @@ if (root == nullptr ) return nullptr; 代码如下: -``` +```cpp if (root->val < low) { TreeNode* right = trimBST(root->right, low, high); // 寻找符合区间[low, high]的节点 return right; @@ -108,7 +108,7 @@ if (root->val < low) { 代码如下: -``` +```cpp if (root->val > high) { TreeNode* left = trimBST(root->left, low, high); // 寻找符合区间[low, high]的节点 return left; @@ -119,7 +119,7 @@ if (root->val > high) { 最后返回root节点,代码如下: -``` +```cpp root->left = trimBST(root->left, low, high); // root->left接入符合条件的左孩子 root->right = trimBST(root->right, low, high); // root->right接入符合条件的右孩子 return root; @@ -133,7 +133,7 @@ return root; 如下代码相当于把节点0的右孩子(节点2)返回给上一层, -``` +```cpp if (root->val < low) { TreeNode* right = trimBST(root->right, low, high); // 寻找符合区间[low, high]的节点 return right; @@ -142,7 +142,7 @@ if (root->val < low) { 然后如下代码相当于用节点3的左孩子 把下一层返回的 节点0的右孩子(节点2) 接住。 -``` +``` cpp root->left = trimBST(root->left, low, high); ```